From 95d11976bd07046e39273bc8059b1ef5df623283 Mon Sep 17 00:00:00 2001 From: Liping Xu <108326363+lipxu@users.noreply.github.com> Date: Fri, 14 Jul 2023 15:44:17 +0800 Subject: [PATCH] update rsyslog log size conf (#15821) Why I did it For some devices whose log folder size is larger than 200M, for example, 256M, the LOG_FILE_ROTATE_SIZE_KB should be 16M. and THRESHOLD_KB=$((USABLE_SPACE_KB - (NUM_LOGS_TO_ROTATE * LOG_FILE_ROTATE_SIZE_KB * 2))) = $(( (VAR_LOG_SIZE_KB * 90 / 100) - RESERVED_SPACE_KB)) - (NUM_LOGS_TO_ROTATE * LOG_FILE_ROTATE_SIZE_KB * 2))) = $(( (256M * 90 / 100) - 4096)) - (8 * 16M * 2))) the result would be a negative value Work item tracking Microsoft ADO (number only): 24524827 How I did it Add a case for 400M, if the log folder size is between 200M and 400M, set the log file size to 2M How to verify it Do cmd "sudo logrotate -f /etc/logrotate.conf" on DUT which val/log folder size is 256M, and check the syslog. --- files/image_config/logrotate/rsyslog.j2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/image_config/logrotate/rsyslog.j2 b/files/image_config/logrotate/rsyslog.j2 index 25db65ac48..d2b94ca2eb 100644 --- a/files/image_config/logrotate/rsyslog.j2 +++ b/files/image_config/logrotate/rsyslog.j2 @@ -36,6 +36,8 @@ { {% if var_log_kb <= 204800 %} size 1M +{% elif var_log_kb <= 409600 %} + size 2M {% else %} size 16M {% endif %} @@ -52,6 +54,8 @@ # Adjust LOG_FILE_ROTATE_SIZE_KB to reflect the "size" parameter specified above, in kB {% if var_log_kb <= 204800 %} LOG_FILE_ROTATE_SIZE_KB=1024 +{% elif var_log_kb <= 409600 %} + LOG_FILE_ROTATE_SIZE_KB=2048 {% else %} LOG_FILE_ROTATE_SIZE_KB=16384 {% endif %}