|
|
39a8b9 |
From e95d78dbdc3ea83909d993c84f147bd26563e4a8 Mon Sep 17 00:00:00 2001
|
|
|
39a8b9 |
From: Mohammed Gamal <mgamal@redhat.com>
|
|
|
39a8b9 |
Date: Thu, 30 Jun 2022 11:54:12 +0200
|
|
|
39a8b9 |
Subject: [PATCH] redhat: Implement restart_if correctly to eliminate warnings
|
|
|
39a8b9 |
|
|
|
39a8b9 |
RH-Author: Mohamed Gamal Morsy <mmorsy@redhat.com>
|
|
|
39a8b9 |
RH-MergeRequest: 6: redhat: Fix WALinuxAgent killing network on boot and implement restart_if for Red Hat
|
|
|
39a8b9 |
RH-Commit: [3/3] 1827f4580b35e44ba60e5b176a1cee97023979ef
|
|
|
39a8b9 |
RH-Bugzilla: 2092753
|
|
|
39a8b9 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
39a8b9 |
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
39a8b9 |
|
|
|
39a8b9 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2092753
|
|
|
39a8b9 |
|
|
|
39a8b9 |
restart_if seems to generate some warnings. As errors are not handled correctly.
|
|
|
39a8b9 |
Implement restart_if() the same wat as default.py, but with RH supported commands
|
|
|
39a8b9 |
instead
|
|
|
39a8b9 |
|
|
|
39a8b9 |
Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
|
|
|
39a8b9 |
---
|
|
|
39a8b9 |
azurelinuxagent/common/osutil/redhat.py | 21 ++++++++++-----------
|
|
|
39a8b9 |
1 file changed, 10 insertions(+), 11 deletions(-)
|
|
|
39a8b9 |
|
|
|
39a8b9 |
diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py
|
|
|
39a8b9 |
index 840f7a1d..5c397ae8 100644
|
|
|
39a8b9 |
--- a/azurelinuxagent/common/osutil/redhat.py
|
|
|
39a8b9 |
+++ b/azurelinuxagent/common/osutil/redhat.py
|
|
|
39a8b9 |
@@ -147,15 +147,14 @@ class RedhatOSUtil(Redhat6xOSUtil):
|
|
|
39a8b9 |
"""
|
|
|
39a8b9 |
Restart an interface by bouncing the link.
|
|
|
39a8b9 |
"""
|
|
|
39a8b9 |
- retry_limit=retries+1
|
|
|
39a8b9 |
+ retry_limit = retries + 1
|
|
|
39a8b9 |
for attempt in range(1, retry_limit):
|
|
|
39a8b9 |
- try:
|
|
|
39a8b9 |
- shellutil.run_command(["ip", "link", "set", ifname, "down", "&&", "ip", "link", "set", ifname, "up"])
|
|
|
39a8b9 |
-
|
|
|
39a8b9 |
- except shellutil.CommandError as cmd_err:
|
|
|
39a8b9 |
- logger.warn("failed to restart {0}: return code {1}".format(ifname, cmd_err.returncode))
|
|
|
39a8b9 |
- if attempt < retry_limit:
|
|
|
39a8b9 |
- logger.info("retrying in {0} seconds".format(wait))
|
|
|
39a8b9 |
- time.sleep(wait)
|
|
|
39a8b9 |
- else:
|
|
|
39a8b9 |
- logger.warn("exceeded restart retries")
|
|
|
39a8b9 |
+ return_code = shellutil.run("ip link set {0} down && ip link set {0} up".format(ifname), expected_errors=[1] if attempt < retries else [])
|
|
|
39a8b9 |
+ if return_code == 0:
|
|
|
39a8b9 |
+ return
|
|
|
39a8b9 |
+ logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code))
|
|
|
39a8b9 |
+ if attempt < retry_limit:
|
|
|
39a8b9 |
+ logger.info("retrying in {0} seconds".format(wait))
|
|
|
39a8b9 |
+ time.sleep(wait)
|
|
|
39a8b9 |
+ else:
|
|
|
39a8b9 |
+ logger.warn("exceeded restart retries")
|
|
|
39a8b9 |
--
|
|
|
39a8b9 |
2.35.3
|
|
|
39a8b9 |
|