Skip to content

Commit 0869fd3

Browse files
zzhiyuanyxieca
authored andcommitted
[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.
1 parent e1129c9 commit 0869fd3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

files/image_config/process-reboot-cause/process-reboot-cause

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def main():
109109
log_info("Previous reboot cause: {}".format(previous_reboot_cause))
110110

111111
# Remove the old REBOOT_CAUSE_FILE
112-
os.remove(REBOOT_CAUSE_FILE)
112+
if os.path.exists(REBOOT_CAUSE_FILE):
113+
os.remove(REBOOT_CAUSE_FILE)
113114

114115
# Write a new default reboot cause file for the next reboot
115116
cause_file = open(REBOOT_CAUSE_FILE, "w")

0 commit comments

Comments
 (0)