From 08d60880ff34c7dcb85d0315c9355bfac17fb2fe Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Fri, 3 May 2024 20:37:18 +0900 Subject: [PATCH 1/2] Revert "app-emulation/wa-linux-agent: Disable interface restarting" This reverts commit 9556c7f94b932ded3658738d616c2f666a364ba8 because waagent looks for internal hostname changes and wants to propagate them to the Azure VM properties by issuing a new DHCP request. --- .../wa-linux-agent/files/0001-flatcar-changes.patch | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch index 694ed8b9371..04cccd50347 100644 --- a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch @@ -172,7 +172,7 @@ new file mode 100644 index 00000000..e31b2923 --- /dev/null +++ b/azurelinuxagent/common/osutil/flatcar.py -@@ -0,0 +1,80 @@ +@@ -0,0 +1,78 @@ +# +# Copyright 2023 Microsoft Corporation +# @@ -240,8 +240,6 @@ index 00000000..e31b2923 + Restart an interface by bouncing the link. systemd-networkd observes + this event, and forces a renew of DHCP. + """ -+ logger.info("not restarting interface {}".format(ifname)) -+ return + retry_limit = retries + 1 + for attempt in range(1, retry_limit): + return_code = shellutil.run("ip link set {0} down && ip link set {0} up".format(ifname)) From 6d6ffc025efefb280700a24ebbfff6d2015e1c12 Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Fri, 3 May 2024 20:44:51 +0900 Subject: [PATCH 2/2] app-emulation/wa-linux-agent: Use networkctl to propagate hostname The if-up-down to trigger the DHCP request causes problems. It's better to directly ask systemd-networkd to issue the request. It seems that one needs to use "reconfigure" instead of "forcerenew", so I went with only that instead of somehow trying to see if "forcerenew" has an effect. --- .../files/0001-flatcar-changes.patch | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch index 04cccd50347..f72529dc288 100644 --- a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-flatcar-changes.patch @@ -1,4 +1,4 @@ -From 7382c63bb2c90a1173393faf093002341f830a09 Mon Sep 17 00:00:00 2001 +From 948c6075656fde25703ba402f8cd94715feaa774 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Mon, 27 Feb 2023 15:59:21 +0100 Subject: [PATCH] flatcar changes @@ -12,9 +12,9 @@ Signed-off-by: Jeremi Piotrowski .../common/persist_firewall_rules.py | 1 + config/flatcar/waagent.conf | 122 ++++++++++++++++++ init/flatcar/10-waagent-sysext.conf | 2 + - init/flatcar/waagent.service | 30 +++++ + init/flatcar/waagent.service | 31 +++++ setup.py | 20 ++- - 9 files changed, 312 insertions(+), 43 deletions(-) + 9 files changed, 313 insertions(+), 43 deletions(-) create mode 100644 azurelinuxagent/common/osutil/coreoscommon.py create mode 100644 azurelinuxagent/common/osutil/flatcar.py create mode 100644 config/flatcar/waagent.conf @@ -83,7 +83,7 @@ index 373727e2..63578932 100644 pass diff --git a/azurelinuxagent/common/osutil/coreoscommon.py b/azurelinuxagent/common/osutil/coreoscommon.py new file mode 100644 -index 00000000..66eae16e +index 00000000..9008ff20 --- /dev/null +++ b/azurelinuxagent/common/osutil/coreoscommon.py @@ -0,0 +1,59 @@ @@ -169,7 +169,7 @@ index 83123e3f..b9257a9b 100644 if distro_name in ("suse", "sle_hpc", "sles", "opensuse"): diff --git a/azurelinuxagent/common/osutil/flatcar.py b/azurelinuxagent/common/osutil/flatcar.py new file mode 100644 -index 00000000..e31b2923 +index 00000000..eeaf25ce --- /dev/null +++ b/azurelinuxagent/common/osutil/flatcar.py @@ -0,0 +1,78 @@ @@ -242,7 +242,7 @@ index 00000000..e31b2923 + """ + retry_limit = retries + 1 + for attempt in range(1, retry_limit): -+ return_code = shellutil.run("ip link set {0} down && ip link set {0} up".format(ifname)) ++ return_code = shellutil.run("networkctl reconfigure {0}".format(ifname)) + if return_code == 0: + return + logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code)) @@ -401,7 +401,7 @@ index 00000000..f756dbc9 +Upholds=waagent.service diff --git a/init/flatcar/waagent.service b/init/flatcar/waagent.service new file mode 100644 -index 00000000..d0d6f7c8 +index 00000000..8d2c1f09 --- /dev/null +++ b/init/flatcar/waagent.service @@ -0,0 +1,31 @@ @@ -469,5 +469,5 @@ index 8f5d92b4..35400e09 100755 set_bin_files(data_files, dest=agent_bin_path) set_conf_files(data_files, dest="/usr/share/defaults/waagent", -- -2.39.2 +2.45.0