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.
This commit is contained in:
Kai Lueke 2024-05-03 20:44:51 +09:00
parent 08d60880ff
commit 6d6ffc025e

View File

@ -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 <knowak@microsoft.com>
Date: Mon, 27 Feb 2023 15:59:21 +0100
Subject: [PATCH] flatcar changes
@ -12,9 +12,9 @@ Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
.../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