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

[logrotate] Fix logrotate failure when asic.conf absent. #15933

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

puffc
Copy link
Contributor

@puffc puffc commented Jul 21, 2023

fixes #15932

Why I did it

The current logrotate postrotate script can be able to rotate swss.rec and sairedis.rec for multiasic platform. However, for single asic platform, the postrotate script doesn't work due to $NUM_ASIC is unset.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Use brace expansion to set default value 1 if NUM_ASIC is null or unset. Please note that the postrotate script will be executed by posix shell only.

How to verify it

logrotate manually:

admin@sonic:~$ ls /var/log/swss -la
total 16
drwxr-xr-x 2 root root 4096 Jul 21 14:56 .
drwxr-xr-x 7 root root 4096 Jul 21 14:54 ..
-rw-r--r-- 1 root root  831 Jul 21 14:57 sairedis.rec
-rw-r--r-- 1 root root   45 Jul 21 14:57 swss.rec
admin@sonic:~$ sudo /usr/sbin/logrotate -f /etc/logrotate.conf
admin@sonic:~$ ls /var/log/swss -la
total 396
drwxr-xr-x 2 root root   4096 Jul 21 14:58 .
drwxr-xr-x 7 root root   4096 Jul 21 14:58 ..
-rw-r--r-- 1 root root  17743 Jul 21 14:58 sairedis.rec
-rw-r--r-- 1 root root 331513 Jul 21 14:58 sairedis.rec.1
-rw-r--r-- 1 root root      0 Jul 21 14:58 swss.rec
-rw-r--r-- 1 root root  41857 Jul 21 14:57 swss.rec.1
admin@sonic:~$ sudo cat /var/log/syslog|grep logrotate
Jul 21 14:58:03.481929 sonic INFO logrotate: Sending SIGHUP to OA log_file_name: /var/log/swss/sairedis.rec
Jul 21 14:58:04.673242 sonic INFO logrotate: Sending SIGHUP to OA log_file_name: /var/log/swss/swss.rec

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Julian Chang - TW (HW3) <julianc@supermicro.com.tw>
@puffc puffc requested a review from lguohan as a code owner July 21, 2023 15:04
@puffc
Copy link
Contributor Author

puffc commented Jul 21, 2023

@lguohan @arlakshm @prgeor Could you please review/merge this PR?

Copy link
Contributor

@saiarcot895 saiarcot895 left a comment

Choose a reason for hiding this comment

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

Looks like this has been working so far because -gt 1 (when asic.conf is missing and NUM_ASIC is undefined) is an error, but is treated as false for the purposes of the if-condition, and it goes into the single ASIC path, but yes, this should be fixed.

@puffc
Copy link
Contributor Author

puffc commented Aug 3, 2023

@qiluo-msft Need your help to review/merge this PR. Thanks!

2 similar comments
@puffc
Copy link
Contributor Author

puffc commented Aug 12, 2023

@qiluo-msft Need your help to review/merge this PR. Thanks!

@puffc
Copy link
Contributor Author

puffc commented Aug 26, 2023

@qiluo-msft Need your help to review/merge this PR. Thanks!

@puffc
Copy link
Contributor Author

puffc commented Sep 23, 2023

@lguohan Would you please review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[logrotate] logrotate failure when asic.conf absent
2 participants