|
|
5a2032 |
From ac21739b94266387360a7ba2b3cfeb44c3df5b01 Mon Sep 17 00:00:00 2001
|
|
|
5a2032 |
From: Mohammed Gamal <mgamal@redhat.com>
|
|
|
5a2032 |
Date: Wed, 22 Jun 2022 13:36:07 +0200
|
|
|
5a2032 |
Subject: [PATCH] redhat: Fix command sequence for restarting net interface
|
|
|
5a2032 |
|
|
|
5a2032 |
RH-Author: Mohamed Gamal Morsy <mmorsy@redhat.com>
|
|
|
5a2032 |
RH-MergeRequest: 4: redhat: Fix command sequence for restarting net interface
|
|
|
5a2032 |
RH-Commit: [1/1] ac14220635c30b3361399ae33a5ecd4e7d8cf92b
|
|
|
5a2032 |
RH-Bugzilla: 2080826
|
|
|
5a2032 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5a2032 |
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
5a2032 |
|
|
|
5a2032 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2080826
|
|
|
5a2032 |
|
|
|
5a2032 |
Apparently the down and up commands need to be run in the same command, so
|
|
|
5a2032 |
connect them together with "&&" operator. Also re-implement restart_if ot handle
|
|
|
5a2032 |
warnings same wat as other distros
|
|
|
5a2032 |
|
|
|
5a2032 |
Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
|
|
|
5a2032 |
---
|
|
|
5a2032 |
azurelinuxagent/common/osutil/redhat.py | 22 ++++++++++------------
|
|
|
5a2032 |
1 file changed, 10 insertions(+), 12 deletions(-)
|
|
|
5a2032 |
|
|
|
5a2032 |
diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py
|
|
|
5a2032 |
index a02647cd..5c397ae8 100644
|
|
|
5a2032 |
--- a/azurelinuxagent/common/osutil/redhat.py
|
|
|
5a2032 |
+++ b/azurelinuxagent/common/osutil/redhat.py
|
|
|
5a2032 |
@@ -147,16 +147,14 @@ class RedhatOSUtil(Redhat6xOSUtil):
|
|
|
5a2032 |
"""
|
|
|
5a2032 |
Restart an interface by bouncing the link.
|
|
|
5a2032 |
"""
|
|
|
5a2032 |
- retry_limit=retries+1
|
|
|
5a2032 |
+ retry_limit = retries + 1
|
|
|
5a2032 |
for attempt in range(1, retry_limit):
|
|
|
5a2032 |
- try:
|
|
|
5a2032 |
- shellutil.run_command(["ip", "link", "set", ifname, "down"])
|
|
|
5a2032 |
- shellutil.run_command(["ip", "link", "set", ifname, "up"])
|
|
|
5a2032 |
-
|
|
|
5a2032 |
- except shellutil.CommandError as cmd_err:
|
|
|
5a2032 |
- logger.warn("failed to restart {0}: return code {1}".format(ifname, cmd_err.returncode))
|
|
|
5a2032 |
- if attempt < retry_limit:
|
|
|
5a2032 |
- logger.info("retrying in {0} seconds".format(wait))
|
|
|
5a2032 |
- time.sleep(wait)
|
|
|
5a2032 |
- else:
|
|
|
5a2032 |
- logger.warn("exceeded restart retries")
|
|
|
5a2032 |
+ return_code = shellutil.run("ip link set {0} down && ip link set {0} up".format(ifname), expected_errors=[1] if attempt < retries else [])
|
|
|
5a2032 |
+ if return_code == 0:
|
|
|
5a2032 |
+ return
|
|
|
5a2032 |
+ logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code))
|
|
|
5a2032 |
+ if attempt < retry_limit:
|
|
|
5a2032 |
+ logger.info("retrying in {0} seconds".format(wait))
|
|
|
5a2032 |
+ time.sleep(wait)
|
|
|
5a2032 |
+ else:
|
|
|
5a2032 |
+ logger.warn("exceeded restart retries")
|
|
|
5a2032 |
--
|
|
|
5a2032 |
2.35.3
|
|
|
5a2032 |
|