From 39a8b9c9dc07fed5e4ccb9ae88ad45f9c4ab1f50 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 02 2022 07:10:39 +0000 Subject: import WALinuxAgent-2.3.0.2-2.el8_6.2 --- diff --git a/SOURCES/wla-Fix-if-hangs-2283.patch b/SOURCES/wla-Fix-if-hangs-2283.patch new file mode 100644 index 0000000..3d4b4bd --- /dev/null +++ b/SOURCES/wla-Fix-if-hangs-2283.patch @@ -0,0 +1,127 @@ +From b415b30624f0dcbe9fd574c28593e8fd38a8d9c8 Mon Sep 17 00:00:00 2001 +From: Mohammed Gamal +Date: Thu, 2 Jun 2022 14:39:42 +0200 +Subject: [PATCH 1/2] Fix if hangs (#2283) + +RH-Author: Mohamed Gamal Morsy +RH-MergeRequest: 2: Fix if hangs (#2283) +RH-Commit: [1/2] cf3b0a2d65eb9eeeceab6d74e376e729e06a01ed +RH-Bugzilla: 2092753 +RH-Acked-by: Vitaly Kuznetsov +RH-Acked-by: Cathy Avery + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2092753 + +Signed-off-by: Laveesh Rohra +(cherry picked from commit 05cd6437ba90928788ef18c8b9fc8a6dbaf47c7d) + +Signed-off-by: Mohammed Gamal +--- + azurelinuxagent/common/osutil/default.py | 26 ++++++++---------------- + azurelinuxagent/common/osutil/ubuntu.py | 22 +++++++++----------- + tests/common/osutil/test_default.py | 11 +++------- + 3 files changed, 21 insertions(+), 38 deletions(-) + +diff --git a/azurelinuxagent/common/osutil/default.py b/azurelinuxagent/common/osutil/default.py +index 066e1431..820016c1 100644 +--- a/azurelinuxagent/common/osutil/default.py ++++ b/azurelinuxagent/common/osutil/default.py +@@ -1163,25 +1163,15 @@ class DefaultOSUtil(object): + def restart_if(self, ifname, retries=3, wait=5): + retry_limit = retries + 1 + for attempt in range(1, retry_limit): +- try: +- shellutil.run_command(["ifdown", ifname]) +- shellutil.run_command(["ifup", ifname]) ++ return_code = shellutil.run("ifdown {0} && ifup {0}".format(ifname), expected_errors=[1] if attempt < retries else []) ++ if return_code == 0: + return +- except shellutil.CommandError as cmd_err: +- +- msg = "failed to restart {0}: returncode={1}\n[stdout]{2}\n\n[stderr]{3}\n"\ +- .format(ifname, cmd_err.returncode, cmd_err.stdout, cmd_err.stderr) +- +- if cmd_err.returncode == 1: +- logger.info(msg) +- else: +- logger.warn(msg) +- +- if attempt < retry_limit: +- logger.info("retrying in {0} seconds".format(wait)) +- time.sleep(wait) +- else: +- logger.warn("exceeded restart retries") ++ logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code)) ++ if attempt < retry_limit: ++ logger.info("retrying in {0} seconds".format(wait)) ++ time.sleep(wait) ++ else: ++ logger.warn("exceeded restart retries") + + def publish_hostname(self, hostname): + self.set_dhcp_hostname(hostname) +diff --git a/azurelinuxagent/common/osutil/ubuntu.py b/azurelinuxagent/common/osutil/ubuntu.py +index 249e1120..5a21511c 100644 +--- a/azurelinuxagent/common/osutil/ubuntu.py ++++ b/azurelinuxagent/common/osutil/ubuntu.py +@@ -142,19 +142,17 @@ class UbuntuOSUtil(Ubuntu16OSUtil): + Restart an interface by bouncing the link. systemd-networkd observes + this event, and forces a renew of DHCP. + """ +- retry_limit=retries+1 ++ retry_limit = retries+1 + for attempt in range(1, retry_limit): +- try: +- shellutil.run_command(["ip", "link", "set", ifname, "down"]) +- shellutil.run_command(["ip", "link", "set", ifname, "up"]) +- +- except shellutil.CommandError as cmd_err: +- logger.warn("failed to restart {0}: return code {1}".format(ifname, cmd_err.returncode)) +- if attempt < retry_limit: +- logger.info("retrying in {0} seconds".format(wait)) +- time.sleep(wait) +- else: +- logger.warn("exceeded restart retries") ++ return_code = shellutil.run("ip link set {0} down && ip link set {0} up".format(ifname)) ++ if return_code == 0: ++ return ++ logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code)) ++ if attempt < retry_limit: ++ logger.info("retrying in {0} seconds".format(wait)) ++ time.sleep(wait) ++ else: ++ logger.warn("exceeded restart retries") + + + class UbuntuSnappyOSUtil(Ubuntu14OSUtil): +diff --git a/tests/common/osutil/test_default.py b/tests/common/osutil/test_default.py +index 65d7ae0f..d6eae68f 100644 +--- a/tests/common/osutil/test_default.py ++++ b/tests/common/osutil/test_default.py +@@ -49,20 +49,15 @@ class TestOSUtil(AgentTestCase): + # setup + retries = 3 + ifname = 'dummy' +- with patch.object(shellutil, "run_command") as run_patch: +- run_patch.side_effect = shellutil.CommandError("ifupdown dummy", 1, "", "") ++ with patch.object(shellutil, "run") as run_patch: ++ run_patch.return_value = 1 + + # execute + osutil.DefaultOSUtil.restart_if(osutil.DefaultOSUtil(), ifname=ifname, retries=retries, wait=0) + + # assert + self.assertEqual(run_patch.call_count, retries) +- cmd_queue = list(args[0] for (args, _) in run_patch.call_args_list) +- while cmd_queue: +- self.assertEqual(cmd_queue.pop(0), ["ifdown", ifname]) +- # We don't expect the following command to be called because 'dummy' does +- # not exist. +- self.assertNotEqual(cmd_queue[0] if cmd_queue else None, ["ifup", ifname]) ++ self.assertEqual(run_patch.call_args_list[0][0][0], 'ifdown {0} && ifup {0}'.format(ifname)) + + def test_get_dvd_device_success(self): + with patch.object(os, 'listdir', return_value=['cpu', 'cdrom0']): +-- +2.31.1 + diff --git a/SOURCES/wla-Implement-restart_if-for-RedHat-OS.patch b/SOURCES/wla-Implement-restart_if-for-RedHat-OS.patch new file mode 100644 index 0000000..8e58daf --- /dev/null +++ b/SOURCES/wla-Implement-restart_if-for-RedHat-OS.patch @@ -0,0 +1,48 @@ +From ab69ae533c18db1f468e7433984b36159612c0d0 Mon Sep 17 00:00:00 2001 +From: Mohammed Gamal +Date: Tue, 17 May 2022 10:50:59 +0200 +Subject: [PATCH 2/2] Implement restart_if for RedHat OS + +RH-Author: Mohamed Gamal Morsy +RH-MergeRequest: 2: Fix if hangs (#2283) +RH-Commit: [2/2] ba8712ff724d5f3cd8bd0b19f5849c854f6c99ca +RH-Bugzilla: 2092753 +RH-Acked-by: Vitaly Kuznetsov +RH-Acked-by: Cathy Avery + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2092753 + +Signed-off-by: Vitaly Kuznetsov +Signed-off-by: Mohammed Gamal +--- + azurelinuxagent/common/osutil/redhat.py | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py +index 9759d113..840f7a1d 100644 +--- a/azurelinuxagent/common/osutil/redhat.py ++++ b/azurelinuxagent/common/osutil/redhat.py +@@ -142,3 +142,20 @@ class RedhatOSUtil(Redhat6xOSUtil): + endpoint = self.get_endpoint_from_leases_path('/var/lib/NetworkManager/dhclient-*.lease') + + return endpoint ++ ++ def restart_if(self, ifname, retries=3, wait=5): ++ """ ++ Restart an interface by bouncing the link. ++ """ ++ retry_limit=retries+1 ++ for attempt in range(1, retry_limit): ++ try: ++ shellutil.run_command(["ip", "link", "set", ifname, "down", "&&", "ip", "link", "set", ifname, "up"]) ++ ++ except shellutil.CommandError as cmd_err: ++ logger.warn("failed to restart {0}: return code {1}".format(ifname, cmd_err.returncode)) ++ if attempt < retry_limit: ++ logger.info("retrying in {0} seconds".format(wait)) ++ time.sleep(wait) ++ else: ++ logger.warn("exceeded restart retries") +-- +2.31.1 + diff --git a/SOURCES/wla-redhat-Implement-restart_if-correctly-to-eliminate-w.patch b/SOURCES/wla-redhat-Implement-restart_if-correctly-to-eliminate-w.patch new file mode 100644 index 0000000..a2efe55 --- /dev/null +++ b/SOURCES/wla-redhat-Implement-restart_if-correctly-to-eliminate-w.patch @@ -0,0 +1,56 @@ +From e95d78dbdc3ea83909d993c84f147bd26563e4a8 Mon Sep 17 00:00:00 2001 +From: Mohammed Gamal +Date: Thu, 30 Jun 2022 11:54:12 +0200 +Subject: [PATCH] redhat: Implement restart_if correctly to eliminate warnings + +RH-Author: Mohamed Gamal Morsy +RH-MergeRequest: 6: redhat: Fix WALinuxAgent killing network on boot and implement restart_if for Red Hat +RH-Commit: [3/3] 1827f4580b35e44ba60e5b176a1cee97023979ef +RH-Bugzilla: 2092753 +RH-Acked-by: Miroslav Rezanina +RH-Acked-by: Vitaly Kuznetsov + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2092753 + +restart_if seems to generate some warnings. As errors are not handled correctly. +Implement restart_if() the same wat as default.py, but with RH supported commands +instead + +Signed-off-by: Mohammed Gamal +--- + azurelinuxagent/common/osutil/redhat.py | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py +index 840f7a1d..5c397ae8 100644 +--- a/azurelinuxagent/common/osutil/redhat.py ++++ b/azurelinuxagent/common/osutil/redhat.py +@@ -147,15 +147,14 @@ class RedhatOSUtil(Redhat6xOSUtil): + """ + Restart an interface by bouncing the link. + """ +- retry_limit=retries+1 ++ retry_limit = retries + 1 + for attempt in range(1, retry_limit): +- try: +- shellutil.run_command(["ip", "link", "set", ifname, "down", "&&", "ip", "link", "set", ifname, "up"]) +- +- except shellutil.CommandError as cmd_err: +- logger.warn("failed to restart {0}: return code {1}".format(ifname, cmd_err.returncode)) +- if attempt < retry_limit: +- logger.info("retrying in {0} seconds".format(wait)) +- time.sleep(wait) +- else: +- logger.warn("exceeded restart retries") ++ return_code = shellutil.run("ip link set {0} down && ip link set {0} up".format(ifname), expected_errors=[1] if attempt < retries else []) ++ if return_code == 0: ++ return ++ logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code)) ++ if attempt < retry_limit: ++ logger.info("retrying in {0} seconds".format(wait)) ++ time.sleep(wait) ++ else: ++ logger.warn("exceeded restart retries") +-- +2.35.3 + diff --git a/SPECS/WALinuxAgent.spec b/SPECS/WALinuxAgent.spec index 8344ba3..97dda6e 100644 --- a/SPECS/WALinuxAgent.spec +++ b/SPECS/WALinuxAgent.spec @@ -1,7 +1,7 @@ Summary: Microsoft Azure Linux Agent Name: WALinuxAgent Version: 2.3.0.2 -Release: 2%{?dist} +Release: 2%{?dist}.2 License: ASL 2.0 Group: Development/Libraries @@ -10,6 +10,12 @@ Source0: WALinuxAgent-2.3.0.2.tar.gz BuildArch: noarch Patch0001: 0001-Add-inital-redhat-build-support.patch +# For bz#2092753 - [Azure][WALA][RHEL-8] [8.6.z] walinuxagent kills network during boot [rhel-8.6.0.z] +Patch2: wla-Fix-if-hangs-2283.patch +# For bz#2092753 - [Azure][WALA][RHEL-8] [8.6.z] walinuxagent kills network during boot [rhel-8.6.0.z] +Patch3: wla-Implement-restart_if-for-RedHat-OS.patch +# For bz#2092753 - [Azure][WALA][RHEL-8] [8.6.z] walinuxagent kills network during boot [rhel-8.6.0.z] +Patch4: wla-redhat-Implement-restart_if-correctly-to-eliminate-w.patch # rhel requirements BuildRequires: python3-devel @@ -43,6 +49,9 @@ Udev rules specific to Microsoft Azure Virtual Machines. %setup -q %patch0001 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build %py3_build @@ -78,6 +87,17 @@ rm -rf $RPM_BUILD_ROOT %{_udevrulesdir}/*.rules %changelog +* Tue Jul 12 2022 Camilla Conte - 2.3.0.2-2.el8_6.2 +- wla-redhat-Implement-restart_if-correctly-to-eliminate-w.patch [bz#2092753] +- Resolves: bz#2092753 + ([Azure][WALA][RHEL-8] [8.6.z] walinuxagent kills network during boot [rhel-8.6.0.z]) + +* Wed Jun 22 2022 Miroslav Rezanina - 2.3.0.2-2.el8_6.1 +- wla-Fix-if-hangs-2283.patch [bz#2092753] +- wla-Implement-restart_if-for-RedHat-OS.patch [bz#2092753] +- Resolves: bz#2092753 + ([Azure][WALA][RHEL-8] [8.6.z] walinuxagent kills network during boot [rhel-8.6.0.z]) + * Mon Aug 09 2021 Miroslav Rezanina - 2.3.0.2-2 - wla-Require-iptables-for-setting-up-persistent-firewall-.patch [bz#1985198] - Resolves: bz#1985198