Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[process-reboot-cause] If software reboot cause is unknown add note if first boot into new image #4538

Merged
merged 3 commits into from
May 7, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions files/image_config/process-reboot-cause/process-reboot-cause
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ REBOOT_TYPE_KEXEC_FILE = "/proc/cmdline"
REBOOT_TYPE_KEXEC_PATTERN_WARM = ".*SONIC_BOOT_TYPE=(warm|fastfast).*"
REBOOT_TYPE_KEXEC_PATTERN_FAST = ".*SONIC_BOOT_TYPE=(fast|fast-reboot).*"

UNKNOWN_REBOOT_CAUSE = "Unknown"
REBOOT_CAUSE_UNKNOWN = "Unknown"
REBOOT_CAUSE_SONIC_IMAGE_INSTALL = "SONiC image installation"


# ========================== Syslog wrappers ==========================
Expand Down Expand Up @@ -72,7 +73,7 @@ def parse_warmfast_reboot_from_proc_cmdline():


def find_software_reboot_cause():
software_reboot_cause = UNKNOWN_REBOOT_CAUSE
software_reboot_cause = REBOOT_CAUSE_UNKNOWN

if os.path.isfile(REBOOT_CAUSE_FILE):
with open(REBOOT_CAUSE_FILE, "r") as cause_file:
Expand All @@ -82,6 +83,8 @@ def find_software_reboot_cause():
log_info("Reboot cause file {} not found".format(REBOOT_CAUSE_FILE))

if os.path.isfile(FIRST_BOOT_PLATFORM_FILE):
if software_reboot_cause == REBOOT_CAUSE_UNKNOWN:
software_reboot_cause = REBOOT_CAUSE_SONIC_IMAGE_INSTALL
lguohan marked this conversation as resolved.
Show resolved Hide resolved
os.remove(FIRST_BOOT_PLATFORM_FILE)

return software_reboot_cause
Expand Down Expand Up @@ -148,7 +151,7 @@ def main():
os.remove(PREVIOUS_REBOOT_CAUSE_FILE)

# Set a default previous reboot cause
previous_reboot_cause = UNKNOWN_REBOOT_CAUSE
previous_reboot_cause = REBOOT_CAUSE_UNKNOWN

# 1. Check if the previous reboot was warm/fast reboot by testing whether there is "fast|fastfast|warm" in /proc/cmdline
proc_cmdline_reboot_cause = find_proc_cmdline_reboot_cause()
Expand Down Expand Up @@ -188,7 +191,7 @@ def main():

# Write a new default reboot cause file for the next reboot
with open(REBOOT_CAUSE_FILE, "w") as cause_file:
cause_file.write(UNKNOWN_REBOOT_CAUSE)
cause_file.write(REBOOT_CAUSE_UNKNOWN)


if __name__ == "__main__":
Expand Down