From 17f198eea6902c0380a8dee5e1f168b60d58eb17 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 15 May 2024 12:36:49 +0800 Subject: [PATCH] [TACACS] Handle log rotate failed issue (#12821) Handle log rotate failed issue #### Why I did it sonic test_ro_disk test case failed because log rotate command failed. #### How I did it Ignore log rotate failed because log already rotating #### How to verify it Pass all test case. #### Description for the changelog Handle log rotate failed issue --- tests/tacacs/test_ro_disk.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/tacacs/test_ro_disk.py b/tests/tacacs/test_ro_disk.py index 55a080621fd..466e40def78 100644 --- a/tests/tacacs/test_ro_disk.py +++ b/tests/tacacs/test_ro_disk.py @@ -179,7 +179,14 @@ def test_ro_disk(localhost, ptfhost, duthosts, enum_rand_one_per_hwsku_hostname, duthost.copy(src=conf_path, dest="/etc/rsyslog.d/000-ro_disk.conf") # To get file in decent size. Force a rotate - duthost.shell("logrotate --force /etc/logrotate.d/rsyslog") + try: + duthost.shell("logrotate --force /etc/logrotate.d/rsyslog") + except RunAnsibleModuleFail as e: + if "logrotate does not support parallel execution on the same set of logfiles" in e.message: + # command will failed when log already in rotating + logger.warning("logrotate command failed: {}".format(e)) + else: + raise e res = duthost.shell("systemctl restart rsyslog") assert res["rc"] == 0, "failed to restart rsyslog"