Skip to content

Commit 61a9d7e

Browse files
ravaliyelmssonicbld
authored andcommitted
Adding fix to clear logs before reboot for disk out of space issue (sonic-net#20323)
What is the motivation for this PR? To proactively prevent disk space issues by cleaning up unnecessary log files in /host/logs_before_reboot during the disk space freeing step. This is especially useful before upgrades, where disk space can be a concern. How did you do it? Added the following line to the disk cleanup routine (typically found in the free_up_disk_space function): exec_command(module, "rm -rf /host/logs_before_reboot/*", ignore_error=True) This line is placed with other similar cleanup commands for logs, cores, dumps, etc. How did you verify/test it? Tested the updated cleanup routine in a testbed and verified that files in /host/logs_before_reboot are deleted as expected. Confirmed that the upgrade process proceeds with sufficient disk space and no residual log files. Any platform specific information? No platform-specific changes. This cleanup is safe for all platforms supported by SONiC testbed. Supported testbed topology if it's a new test case? Not a new test case. This is a framework/testbed maintenance improvement. Documentation No specific documentation updates are required for this change, as it is a maintenance step within the existing disk cleanup routine.
1 parent d8b69d9 commit 61a9d7e

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

ansible/library/reduce_and_add_sonic_images.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ def get_disk_total_size(module):
367367
exec_command(module, "rm -f /var/core/*", ignore_error=True)
368368
exec_command(module, "rm -rf /var/dump/*", ignore_error=True)
369369
exec_command(module, "rm -rf /home/admin/*", ignore_error=True)
370+
exec_command(module, "rm -rf /host/logs_before_reboot/*", ignore_error=True)
370371
latest_used_percent = get_disk_used_percent(module)
371372
log("Done free up, latest used percent: {}".format(latest_used_percent))
372373
else:

0 commit comments

Comments
 (0)