Skip to content

Commit 51d9c9f

Browse files
vaibhavhdyxieca
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 03aa77b commit 51d9c9f

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
@@ -777,6 +777,17 @@ fi
777777
778778
# Reboot: explicitly call Linux native reboot under sbin
779779
debug "Rebooting with ${REBOOT_METHOD} to ${NEXT_SONIC_IMAGE} ..."
780+
781+
LOGS_ON_TMPFS=0
782+
df --output=fstype /var/log* | grep -c 'tmpfs' || LOGS_ON_TMPFS=$?
783+
if [[ LOGS_ON_TMPFS -eq 0 ]]; then
784+
debug "Backup shutdown logs to /host/logs_before_reboot"
785+
mkdir -p /host/logs_before_reboot || /bin/true
786+
# maxdepth 2: find files within 2 nested directories (eg. /var/log/ and /var/log/swss/)
787+
# mmin 30: find files written in past 30 minutes
788+
find /var/log -maxdepth 2 -mmin -30 -type f | xargs -I {} cp {} /host/logs_before_reboot/ || /bin/true
789+
fi
790+
780791
exec ${REBOOT_METHOD}
781792
782793
# Should never reach here

0 commit comments

Comments
 (0)