From ad1ed4ef6462064f7989a18c477e277cdd0633ec Mon Sep 17 00:00:00 2001 From: Renuka Manavalan <47282725+renukamanavalan@users.noreply.github.com> Date: Thu, 20 Jan 2022 15:36:02 -0800 Subject: [PATCH] [generic_config_updater] Minor update - No logical code change (#2028) What I did Missed update from review comments in PR #2020 s/os.system("sleep 10s")/time.sleep(10)/ --- generic_config_updater/services_validator.py | 3 ++- tests/generic_config_updater/service_validator_test.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic_config_updater/services_validator.py b/generic_config_updater/services_validator.py index f69e870ed657..01bad16d8556 100644 --- a/generic_config_updater/services_validator.py +++ b/generic_config_updater/services_validator.py @@ -1,4 +1,5 @@ import os +import time from .gu_common import genericUpdaterLogging logger = genericUpdaterLogging.get_logger(title="Service Validator") @@ -33,7 +34,7 @@ def _service_restart(svc_name): logger.log(logger.LOG_PRIORITY_ERROR, f"Restart failed for {svc_name} rc={rc} after reset; Pause for 10s & retry", print_to_console) - os.system("sleep 10s") + time.sleep(10) rc = os.system(f"systemctl restart {svc_name}") if rc == 0: diff --git a/tests/generic_config_updater/service_validator_test.py b/tests/generic_config_updater/service_validator_test.py index 470e5428a79e..dcfc5a41cc71 100644 --- a/tests/generic_config_updater/service_validator_test.py +++ b/tests/generic_config_updater/service_validator_test.py @@ -67,7 +67,6 @@ def mock_os_system_call(cmd): { "cmd": "systemctl restart rsyslog", "rc": 1 }, # rsyslog restart; fails { "cmd": "systemctl reset-failed rsyslog", "rc": 1 }, # reset; failure here just logs { "cmd": "systemctl restart rsyslog", "rc": 1 }, # restart again; fails - { "cmd": "sleep 10s", "rc": 0 }, # sleep; rc ignored { "cmd": "systemctl restart rsyslog", "rc": 1 }, # restart again; fails ]