Skip to content

Added exception handling for force rotate logs#2206

Merged
yxieca merged 3 commits intosonic-net:masterfrom
OleksandrKozodoi:add_exception_handling_for_force_rotate_logs
Sep 14, 2020
Merged

Added exception handling for force rotate logs#2206
yxieca merged 3 commits intosonic-net:masterfrom
OleksandrKozodoi:add_exception_handling_for_force_rotate_logs

Conversation

@OleksandrKozodoi
Copy link
Contributor

Signed-off-by: Oleksandr Kozodoi oleksandrx.kozodoi@intel.com

Description of PR

Summary:
PR #2161 added force rotate logs. We are observing that log rotate contains duplicate log entries (see below). In this case duthost.shell("/usr/sbin/logrotate -f /etc/logrotate.conf > /dev/null 2>&1") command is failed and logs are rotated. As result test case is failed as well. This commit is to address this issue.

sudo /usr/sbin/logrotate -d /etc/logrotate.conf

reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file alternatives
reading config file apt
reading config file btmp
reading config file dpkg
error: dpkg:10 duplicate log entry for /var/log/alternatives.log
error: found error in file dpkg, skipping
reading config file monit

cat /etc/logrotate.d/alternatives

/var/log/alternatives.log {
        monthly
        rotate 12
        compress
        delaycompress
        missingok
        notifempty
        create 644 root root
}
cat /etc/logrotate.d/dpkg

/var/log/dpkg.log {
        size 100k
        rotate 1
        compress
        delaycompress
        missingok
        notifempty
        create 644 root root
}
/var/log/alternatives.log {
        size 100k
        rotate 1
        compress
        delaycompress
        missingok
        notifempty
        create 644 root root
}

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

Loganalyzer failed if we rotate logs and duplicate log entries are present in configuration files.

How did you do it?

Added exception handling for logrotate command and log appropriate warning message.

How did you verify/test it?

Run test.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

Signed-off-by: Oleksandr Kozodoi <oleksandrx.kozodoi@intel.com>
@OleksandrKozodoi
Copy link
Contributor Author

@lolyu Please review

@OleksandrKozodoi
Copy link
Contributor Author

@akokhan @SavchukRomanLv Please review

"/usr/sbin/logrotate -f /etc/logrotate.conf > /dev/null 2>&1"
)
except RunAnsibleModuleFail as e:
logging.warning("logrotate: duplicate log entry in configuration files")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the reason of failure can be different. I'd just log exception message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@daall daall requested review from a team and lolyu September 11, 2020 20:14
@lolyu
Copy link
Collaborator

lolyu commented Sep 12, 2020

I have two questions:

  1. which test case caused this symptom?
  2. Should we remove the redundant log entry?

@OleksandrKozodoi
Copy link
Contributor Author

I have two questions:

  1. which test case caused this symptom?
  2. Should we remove the redundant log entry?
  1. All test cases
  2. We could remove the redundant log entry, but other packages could reproduce this issue in the future. This issue blocks testing the main functionality of SONiC so we should suppress it. The Dev team is working on the issue with the redundant log entry.

Copy link
Collaborator

@lolyu lolyu left a comment

Choose a reason for hiding this comment

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

LGTM

@yxieca yxieca merged commit b000dcd into sonic-net:master Sep 14, 2020
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
utilities;
* 7dae152 2022-07-05 | show linkmgrd status in `show mux status` (sonic-net#2254) (HEAD -> 202205) [Jing Zhang]
* 6ebba53 2022-07-01 | [config/load_mgmt_config] Support load IPv6 mgmt IP (sonic-net#2206) (HEAD -> 202205, github/202205) [Jing Kan]

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
… submodule head (sonic-net#12494)

utilities:
* 02eb899e 2022-07-12 | [config/load_mgmt_config] Support load IPv6 mgmt IP (sonic-net#2206) (sonic-net#2246) (sonic-net#2256) (HEAD -> 201811, github/201811) [Jing Kan]

platform-daemon:
* fc288cc 2022-05-05 | Mem leak caused by Xcvrd in Send-Q of REDIS-DB socket connection (sonic-net#260) (HEAD -> 201811, github/201811) [Prince George]

platform-common:
* edb062b 2022-02-09 | [sonic_sfp] Interpret sff 'int' element =0 as valid value (sonic-net#261) (HEAD -> 201811, github/201811) [Prince George]

kernel:
* 9d2d1a1 2022-02-11 | [201811] Increase log_buf_len size to 1M (HEAD -> 201811, github/201811) [Sujin Kang]
* b34a213 2022-02-10 | [201811] Increase log_buf_len size to 1M [Samuel Angebault]
* c4684cb 2022-02-11 | [201811] Apply kernel patches to fix emmc unreliability [Sujin Kang]
* df68771 2022-02-03 | [201811] Apply kernel patches to fix emmc unreliability [Samuel Angebault]
* f21cb06 2021-03-26 | [ci]: remove 201811 suffix (sonic-net#204) [lguohan]
* 5439b2a 2021-02-08 | [dni_dps460] Add attributes to retrieve PMBus status command codes (sonic-net#194) [Arun Saravanan Balachandran]

Signed-off-by: Ying Xie <ying.xie@microsoft.com>

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
5bb99c7 Validate LAG has members before mirror session create (sonic-net#2130)
ec6c8af [vxlan] Remove tunnel map objects on VNET tunnel removal (sonic-net#2150)
7e7db19 [BFD]Registering BFD state change callback during session creation (sonic-net#2202)
618fe07 [VNET]Fixing nexthop group delete during route change (sonic-net#2198)
91b66df [portsorch]: Prevent LAG member configuration when port has active ACL binding (sonic-net#2165)
29de9d0 Remove redundant and problematic code to skip "pool" field in buffer profile handling (sonic-net#2197)
ded0b45 [PBH] Implement Edit Flows (sonic-net#2169)
2ee0f49 [neighsyncd] increase neighsyncd timeout (sonic-net#2209)
a0160c0 [QosOrch] The notifications cannot be drained in QosOrch in case the first one needs to retry (sonic-net#2206)
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
Why I did it

62b7b56 2022-07-13 | Remove disabled and not loaded services before calling reset-failed and restart services (sonic-net#2266) [Zain Budhwani]  
09b4678 2022-07-05 | [config/load_mgmt_config] Support load IPv6 mgmt IP (sonic-net#2206) (sonic-net#2246) [Jing Kan] 

How I did it

Pulled latest commit from 201911 sonic-utilities branch and created PR

How to verify it

Look at build-image
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.

4 participants