tests: datasourcenone use client.restart to block until done (#4635)
Earlier iterations of this test exposed failure cases where
DataSourceNone and cloud-init status --wait would block indefinitely
in some failure modes. The primary failure mode was DataSourceNone
config on LXD containers due to invalid network config on virtual
NICs due to LP:#2022947 and newer netplan resulting in
tracebacks preventing init local and network boot stages from
persisting completion status to /run/cloud-init/status.json.
This is resolved already within the test by copying working
network config prior to DataSourceNone detection on lxd_containers.
The test can now rely on client.restart default blocking and retries
to avoid expiring all retries on platforms with slower reboots.
bug(schema): write network-config if instance dir present (#4635)
Only write /var/lib/cloud/instance/network-config.json once
datasource is detected. The /var/lib/clound/instance symlink is
created by Init.instancify after datasource detection is complete.
Move creation of /var/lib/cloud/instance/network-config.json into
a separate method _write_network_config_json. It will be called by
any call to apply_network_config.
apply_network_config is called in both Local and Network stages.
In Local stage, apply_network_config is used to either:
- render the final network config of datasource detected in Local
- in absence of Local datasource, render basic fallback DHCP on
primary NIC to allow network to come up before detecting a
Network datasource
For Network datasources, they will not have been discovered or
instancify'd in Local boot stage, so apply_network_config cannot
yet persist network-config.json.
Defer creation of network-config.json for Network datasources
until the link /var/lib/cloud/instance exists and
apply_network_config is called in Network stage to render final
network config.