canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
3.01k stars 887 forks source link

feat: Conditionally remove networkd online dependency on Ubuntu #5772

Closed TheRealFalcon closed 1 month ago

TheRealFalcon commented 1 month ago

Proposed Commit Message

feat: Conditionally remove networkd online dependency on Ubuntu

Traditionally, cloud-init-network.service (previously
cloud-init.service) waited for network connectivity (via systemd
service ordering) before running. This has caused
cloud-init-network.service to block boot for a significant amount of
time. For the vast majority of boots, this network connectivity
isn't required.

This commit removes the ordering
After=systemd-networkd-wait-online.service, but checks the datasource
and user data in the init-local timeframe to see if network
connectivity will be necessary in the init network timeframe.
If so, when the init network service starts, it will call
systemd-networkd-wait-online manually in the same manner that the
systemd-networkd-wait-online.service does to wait for network
connectivity.

This commit affects Ubuntu only due to the various number of service
orderings and network renderers possible, along with the downstream
synchronization needed. However, a new overrideable method in the
Distro class should make this optimization trivial to implement for
any other distro.

Additional Context

Test Steps

Merge type

TheRealFalcon commented 1 month ago

Take 2...

I added a commit that instead of using a drop-in will call the systemd-networkd-wait-online binary using the exact same args that the service uses based on 'systemctl cat'. This removes the need for a costly daemon-reload in the cases we need to wait on network.

I haven't touched integration tests since the first commit, so they will have known failures.

TheRealFalcon commented 1 month ago

@blackboxsw , thanks for the review. I applied your comments and also made a change to move the wait into the activators.

TheRealFalcon commented 1 month ago

updated based on comments. Integration tests still need to be updated.

TheRealFalcon commented 1 month ago

Test case added and no more comments left. I'm going to merge this.