Skip to content

Commit cc78747

Browse files
vaibhavhdqiluo-msft
authored andcommitted
[warm/fast-reboot] Backup logs from tmpfs to disk during fast/warm shutdown (#2714)
Goal: Preserve logs during TOR upgrades and shutdown Need: Below PRs moved logs from disk to tmpfs for specific hwskus. Due to these changes, shutdown path logs are now lost. The logs in shutdown path are crucial for debug purposes. sonic-net/sonic-buildimage#13805 sonic-net/sonic-buildimage#13587 sonic-net/sonic-buildimage#13587 How I did it Check if logs are on tmpfs. If yes, backup logs from /var/log How to verify it Verified on a physical device - logs on tmfs are backed up for past 30 minutes.
1 parent 93c7d43 commit cc78747

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/fast-reboot

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,17 @@ fi
752752
753753
# Reboot: explicitly call Linux native reboot under sbin
754754
debug "Rebooting with ${REBOOT_METHOD} to ${NEXT_SONIC_IMAGE} ..."
755+
756+
LOGS_ON_TMPFS=0
757+
df --output=fstype /var/log* | grep -c 'tmpfs' || LOGS_ON_TMPFS=$?
758+
if [[ LOGS_ON_TMPFS -eq 0 ]]; then
759+
debug "Backup shutdown logs to /host/logs_before_reboot"
760+
mkdir -p /host/logs_before_reboot || /bin/true
761+
# maxdepth 2: find files within 2 nested directories (eg. /var/log/ and /var/log/swss/)
762+
# mmin 30: find files written in past 30 minutes
763+
find /var/log -maxdepth 2 -mmin -30 -type f | xargs -I {} cp {} /host/logs_before_reboot/ || /bin/true
764+
fi
765+
755766
exec ${REBOOT_METHOD}
756767
757768
# Should never reach here

0 commit comments

Comments
 (0)