[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.
This commit is contained in:
zzhiyuan 2019-07-16 08:34:11 -07:00 committed by lguohan
parent b5a4527cb0
commit e4c041b57f

View File

@ -109,7 +109,8 @@ def main():
log_info("Previous reboot cause: {}".format(previous_reboot_cause)) log_info("Previous reboot cause: {}".format(previous_reboot_cause))
# Remove the old REBOOT_CAUSE_FILE # 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 # Write a new default reboot cause file for the next reboot
cause_file = open(REBOOT_CAUSE_FILE, "w") cause_file = open(REBOOT_CAUSE_FILE, "w")