From c567b71239f85f577b9c46cb7189df101745cb5e Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Fri, 20 Sep 2024 10:37:20 -0600 Subject: [PATCH] fix(functions): cloud-init.service renamed cloud-init-network.service In cloud-init version 24.3, single process mode where a shared python systemd service cloud-init-main. In that release, cloud-init.service was renamed cloud-init-network.service to better clarify cloud-init's systemd unit names relative to the cloud-init boot stages. This rename only applies to Oracular and newer releases. See: https://discourse.ubuntu.com/t/announcement-cloud-init-perfomance-optimization-single-process/47505 functions drops in a complete override for cloud-init.service. That override in /etc/systemd/system needs to be renamed and refreshed to latest single process configuration. LP: #2081325 --- live-build/functions | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/live-build/functions b/live-build/functions index 912804ac..9ec51967 100644 --- a/live-build/functions +++ b/live-build/functions @@ -1046,20 +1046,22 @@ EOF # it disables all previous network config in /etc/netplan so # any previous 50-cloud-init.yaml will be rendered inert. - # Position cloud-init.service After=NetworkManager.service. + # Position cloud-init-network.service After=NetworkManager.service. # (LP: #2008952. Drop-in systemd files cannot redact existing # dependencies (Before= or After=). So, replace the entire unit - # with an override in /etc/systemd/system/cloud-init.service. + # with an override in /etc/systemd/system/cloud-init-network.service. # Avoid issues reported by debsums (LP: #2069391) by not overwriting # unit files delivered by the cloud-init deb. # This drop-in will need to track any changes introduced by cloud-init - # SRUs which alter the cloud-init.service unit values. + # SRUs which alter the cloud-init-network.service unit values. # This override can be dropped when NetworkManager.service can run # Before=sysinit.target when it drops strict dbus.service dependency. + # 24.3 renamed cloud-init.service to cloud-init-network.service for + # single process mode mkdir -p chroot/etc/systemd/system/ - cat < chroot/etc/systemd/system/cloud-init.service + cat < chroot/etc/systemd/system/cloud-init-network.service ${AUTOMATION_HEADER} -# Based on cloud-init 24.2 for Desktop LiveCD +# Based on cloud-init 24.3 for Desktop LiveCD # Redact sysinit.target from Before, add After=NetworkManager*.service # (LP: #2008952) [Unit] @@ -1086,7 +1088,14 @@ ConditionEnvironment=!KERNEL_CMDLINE=cloud-init=disabled [Service] Type=oneshot -ExecStart=/usr/bin/cloud-init init +# This service is a shim which preserves systemd ordering while allowing a +# single Python process to run cloud-init's logic. This works by communicating +# with the cloud-init process over a unix socket to tell the process that this +# stage can start, and then wait on a return socket until the cloud-init +# process has completed this stage. The output from the return socket is piped +# into a shell so that the process can send a completion message (defaults to +# "done", otherwise includes an error message) and an exit code to systemd. +ExecStart=sh -c 'echo "start" | netcat -Uu -W1 /run/cloud-init/share/network.sock -s /run/cloud-init/share/network-return.sock | sh' RemainAfterExit=yes TimeoutSec=0