From e4c041b57f832819c111de67f2cf74672103afd5 Mon Sep 17 00:00:00 2001 From: zzhiyuan Date: Tue, 16 Jul 2019 08:34:11 -0700 Subject: [PATCH] [baseimage]: Fix process-reboot-cause possibly throwing OSError (#3159) In case of going from previous iteration of SONiC, and the last reboot was hardware, REBOOT_CAUSE_FILE may not be present and the service may throw an error. --- files/image_config/process-reboot-cause/process-reboot-cause | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/image_config/process-reboot-cause/process-reboot-cause b/files/image_config/process-reboot-cause/process-reboot-cause index 0d5ae78137..81c496a025 100755 --- a/files/image_config/process-reboot-cause/process-reboot-cause +++ b/files/image_config/process-reboot-cause/process-reboot-cause @@ -109,7 +109,8 @@ def main(): log_info("Previous reboot cause: {}".format(previous_reboot_cause)) # Remove the old REBOOT_CAUSE_FILE - os.remove(REBOOT_CAUSE_FILE) + if os.path.exists(REBOOT_CAUSE_FILE): + os.remove(REBOOT_CAUSE_FILE) # Write a new default reboot cause file for the next reboot cause_file = open(REBOOT_CAUSE_FILE, "w")