Merge pull request #1978 from flatcar/kai/azure-hostname

app-emulation/wa-linux-agent: Use networkctl to propagate hostname
This commit is contained in:
Kai Lüke 2024-05-03 23:12:40 +09:00 committed by GitHub
commit f06ebd3692
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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> From: Krzesimir Nowak <knowak@microsoft.com>
Date: Mon, 27 Feb 2023 15:59:21 +0100 Date: Mon, 27 Feb 2023 15:59:21 +0100
Subject: [PATCH] flatcar changes Subject: [PATCH] flatcar changes
@ -12,9 +12,9 @@ Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
.../common/persist_firewall_rules.py | 1 + .../common/persist_firewall_rules.py | 1 +
config/flatcar/waagent.conf | 122 ++++++++++++++++++ config/flatcar/waagent.conf | 122 ++++++++++++++++++
init/flatcar/10-waagent-sysext.conf | 2 + init/flatcar/10-waagent-sysext.conf | 2 +
init/flatcar/waagent.service | 30 +++++ init/flatcar/waagent.service | 31 +++++
setup.py | 20 ++- 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/coreoscommon.py
create mode 100644 azurelinuxagent/common/osutil/flatcar.py create mode 100644 azurelinuxagent/common/osutil/flatcar.py
create mode 100644 config/flatcar/waagent.conf create mode 100644 config/flatcar/waagent.conf
@ -83,7 +83,7 @@ index 373727e2..63578932 100644
pass pass
diff --git a/azurelinuxagent/common/osutil/coreoscommon.py b/azurelinuxagent/common/osutil/coreoscommon.py diff --git a/azurelinuxagent/common/osutil/coreoscommon.py b/azurelinuxagent/common/osutil/coreoscommon.py
new file mode 100644 new file mode 100644
index 00000000..66eae16e index 00000000..9008ff20
--- /dev/null --- /dev/null
+++ b/azurelinuxagent/common/osutil/coreoscommon.py +++ b/azurelinuxagent/common/osutil/coreoscommon.py
@@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
@ -169,10 +169,10 @@ index 83123e3f..b9257a9b 100644
if distro_name in ("suse", "sle_hpc", "sles", "opensuse"): if distro_name in ("suse", "sle_hpc", "sles", "opensuse"):
diff --git a/azurelinuxagent/common/osutil/flatcar.py b/azurelinuxagent/common/osutil/flatcar.py diff --git a/azurelinuxagent/common/osutil/flatcar.py b/azurelinuxagent/common/osutil/flatcar.py
new file mode 100644 new file mode 100644
index 00000000..e31b2923 index 00000000..eeaf25ce
--- /dev/null --- /dev/null
+++ b/azurelinuxagent/common/osutil/flatcar.py +++ b/azurelinuxagent/common/osutil/flatcar.py
@@ -0,0 +1,80 @@ @@ -0,0 +1,78 @@
+# +#
+# Copyright 2023 Microsoft Corporation +# Copyright 2023 Microsoft Corporation
+# +#
@ -240,11 +240,9 @@ index 00000000..e31b2923
+ Restart an interface by bouncing the link. systemd-networkd observes + Restart an interface by bouncing the link. systemd-networkd observes
+ this event, and forces a renew of DHCP. + this event, and forces a renew of DHCP.
+ """ + """
+ logger.info("not restarting interface {}".format(ifname))
+ return
+ retry_limit = retries + 1 + retry_limit = retries + 1
+ for attempt in range(1, retry_limit): + 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: + if return_code == 0:
+ return + return
+ logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code)) + logger.warn("failed to restart {0}: return code {1}".format(ifname, return_code))
@ -403,7 +401,7 @@ index 00000000..f756dbc9
+Upholds=waagent.service +Upholds=waagent.service
diff --git a/init/flatcar/waagent.service b/init/flatcar/waagent.service diff --git a/init/flatcar/waagent.service b/init/flatcar/waagent.service
new file mode 100644 new file mode 100644
index 00000000..d0d6f7c8 index 00000000..8d2c1f09
--- /dev/null --- /dev/null
+++ b/init/flatcar/waagent.service +++ b/init/flatcar/waagent.service
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
@ -471,5 +469,5 @@ index 8f5d92b4..35400e09 100755
set_bin_files(data_files, dest=agent_bin_path) set_bin_files(data_files, dest=agent_bin_path)
set_conf_files(data_files, dest="/usr/share/defaults/waagent", set_conf_files(data_files, dest="/usr/share/defaults/waagent",
-- --
2.39.2 2.45.0