-
Notifications
You must be signed in to change notification settings - Fork 744
Description
What are you trying to do?
Run a cloud-init configuration that leaves the VM in a shutdown state at the end of the process.
Current behavior
When such a cloud-init is used in launching a VM (multipass launch -n a --clout-init cloud-init.yaml), the launching process will continue after the shutdown until it is interrupted or it timeouts (default 300 seconds or --timeout value). This happens because the function wait_for_cloud_init waits until it can check via ssh the existence of the file /var/lib/cloud/instance/boot-finished, signalling the end of the cloud-init configuration. Since this is not possible with a VM in a Shutdown state, it waits until timeout.
What's your proposed solution?
This cloud-init functionality would require parsing the cloud-init file to get an intended final state and if it is not Running (including rebooting, since the machine ends up being running) or simply Shutdown, the wait for the cloud-init does not check for the presence of /var/lib/cloud/instance/boot-finished but just wait until the VM state is the expected one.
Another solution is to just add the check for VM Shutoff and consider the cloud-init done if that is the case, since if that is the intended state, the VM will not perform more actions when it reaches that state (parsing in the previous option should be aware of this). The problem of this option is if something in cloud-init causes a premature shutdown due to a bug or some other problem.
Additional context
Related to #4199, was raised first by @CoenraadS:
Post
I also encountered this using:power_state: mode: poweroff message: "Shutting down VM after preparation" timeout: 30 condition: TrueWhich seems the 'correct' way of shutting down after init. Windows + HyperV