From 7d4608e149468a03e9f58d3feae85b4942a55b94 Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Mon, 20 Dec 2021 16:48:54 +0100 Subject: set-hostname: work around race condition This service sets the hostname on boot to the machine name amended by the serial number unless /etc/hostname already exists. systemd does also set a hostname, if none is available it uses 'localhost' and creates an empty /etc/hostname. This two mechanism have a race condition so that systemd might run before set-hostname was able to create /etc/hostname. Likely only seens a recent systemd update. Fix that by changing the conditions for executing set-hostname to run when there is no or an empty /etc/hostname file. Related-to: ELB-4277 Signed-off-by: Max Krummenacher (cherry picked from commit 2f6a4e41f66496b6719e9b493207b99b9446c837) --- recipes-core/set-hostname/files/set-hostname.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'recipes-core') diff --git a/recipes-core/set-hostname/files/set-hostname.service b/recipes-core/set-hostname/files/set-hostname.service index 306528b..9bd2a63 100644 --- a/recipes-core/set-hostname/files/set-hostname.service +++ b/recipes-core/set-hostname/files/set-hostname.service @@ -1,5 +1,5 @@ [Unit] -ConditionPathExists=|!/etc/hostname +ConditionFileNotEmpty=|!/etc/hostname Wants=network-pre.target Before=network-pre.target After=local-fs.target -- cgit v1.2.3