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

[warm/fast-reboot] Backup logs from tmpfs to disk during fast/warm shutdown #2714

Merged
merged 2 commits into from
Mar 6, 2023
Merged
Changes from 1 commit
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: 11 additions & 0 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,17 @@ fi

# Reboot: explicitly call Linux native reboot under sbin
debug "Rebooting with ${REBOOT_METHOD} to ${NEXT_SONIC_IMAGE} ..."

LOGS_ON_TMPFS=0
df --output=fstype /var/log* | grep 'tmpfs' || LOGS_ON_TMPFS=$?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use grep -c instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated now.

if [[ LOGS_ON_TMPFS -eq 0 ]]; then
debug "Backup shutdown logs to /host/logs_before_reboot"
mkdir -p /host/logs_before_reboot || /bin/true
# maxdepth 2: find files within 2 nested directories (eg. /var/log/ and /var/log/swss/)
# mmin 30: find files written in past 30 minutes
find /var/log -maxdepth 2 -mmin -30 -type f | xargs -I {} cp {} /host/logs_before_reboot/ || /bin/true
fi

exec ${REBOOT_METHOD}

# Should never reach here
Expand Down