[Merge] ~chad.smith/livecd-rootfs:desktop-cloud-init-after-network-manager-ordering into livecd-rootfs:ubuntu/master

Dimitri John Ledkov mp+439586 at code.launchpad.net
Tue Mar 28 10:08:33 UTC 2023


Review: Needs Information converting to a drop-in might be tricky

maybe not =/

Diff comments:

> diff --git a/live-build/functions b/live-build/functions
> index e1f0000..1e81de9 100644
> --- a/live-build/functions
> +++ b/live-build/functions
> @@ -1017,6 +1020,50 @@ system_info:
>      activators: ['network-manager']
>  EOF
>  
> +        # Position cloud-init.service After=NetworkManager.service.
> +        # (LP: #2008952).
> +        # We override the entire cloud-init.service definition because
> +        # systemd drop-in files only allow adding Before/After constraints
> +        # yet we are dropping the Before=sysinit.target from the upstream
> +        # cloud-init.service.
> +        # This override can be dropped when NetworkManager.service can run
> +        # Before=sysinit.target when it drops strict dbus.service dependency.
> +        cat <<EOF > chroot/lib/systemd/system/cloud-init.service
> +${AUTOMATION_HEADER}
> +# Based on cloud-init 23.1 for Desktop LiveCD
> +[Unit]
> +Description=Initial cloud-init job (metadata service crawler)
> +DefaultDependencies=no
> +Wants=cloud-init-local.service
> +Wants=sshd-keygen.service
> +Wants=sshd.service
> +After=cloud-init-local.service
> +After=systemd-networkd-wait-online.service
> +# Installer Added After=NetworkManager* ordering
> +After=NetworkManager.service
> +After=NetworkManager-wait-online.service
> +After=networking.service
> +Before=network-online.target
> +Before=sshd-keygen.service
> +Before=sshd.service
> +# Before=sysinit.target  Installer removed to allow for NM dependency
> +Before=shutdown.target

Or maybe now =/ from:

https://www.freedesktop.org/software/systemd/man/systemd.unit.html

"""
Note that for drop-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), such as AssertPathExists= (or e.g. ExecStart= in service units), one needs to first clear the list before re-adding all entries except the one that is to be removed. Dependencies (After=, etc.) cannot be reset to an empty list, so dependencies can only be added in drop-ins. If you want to remove dependencies, you have to override the entire unit.
"""

I'm not sure if the documentation is out of date, or if the above is still true and maybe one cannot reset the Before= list.

Maybe we will need to patch cloud-init itself, to drop Before=sysinit.target from the cloud-init.service, and move it to a drop-in (which we can then divert/disable/override in a higher path) or even move it to a generator.

Because if cloud-init/netplan is configured to use NetworkManager we need to do all of these things, which we should know about statically ahead of first boot.

I guess further testing and brainstorming will be needed and/or potentially patching cloud-init itself next cycle.

> +Conflicts=shutdown.target
> +Before=systemd-user-sessions.service
> +
> +[Service]
> +Type=oneshot
> +ExecStart=/usr/bin/cloud-init init
> +RemainAfterExit=yes
> +TimeoutSec=0
> +
> +# Output needs to appear in instance console output
> +StandardOutput=journal+console
> +
> +[Install]
> +WantedBy=cloud-init.target
> +EOF
> +
>          # Allow cloud-init clean to inform of strict network-manager config
>          mkdir -p chroot/etc/cloud/clean.d
>          cat <<EOF > chroot/etc/cloud/clean.d/99-installer-use-networkmanager


-- 
https://code.launchpad.net/~chad.smith/livecd-rootfs/+git/livecd-rootfs/+merge/439586
Your team Ubuntu Core Development Team is subscribed to branch livecd-rootfs:ubuntu/master.




More information about the Ubuntu-reviews mailing list