cloudbase / cloudbase-init

Cross-platform instance initialization
http://openstack.org
Apache License 2.0
414 stars 150 forks source link

Is there an equivalent of cloud-init status --wait? #60

Open rgl opened 3 years ago

rgl commented 3 years ago

Is there an equivalent of cloud-init status --wait of cloud-init in cloudbase-init?

ader1990 commented 3 years ago

Hello,

Currently, there is no equivalent. What is the actual problem you want to solve with this feature? For example, you can check the cloudbase-init service status to monitor if the cloudbase-init is still running.

rgl commented 3 years ago

The use case is simple, known when cloudbase-init is done running everything it was told about and I can start using other provisioning method like ansible/vagrant.

For example, setting the hostname needs a reboot, so I should never try to start anything before that.

ader1990 commented 3 years ago

Got it. In this case, I strongly suggest to verify the internal state for cloudbase-init, kept in the registry keys:

hklm://software/cloudbase-init/<id>/plugins/<pluginid>

Cloudbase-Init relies on a plugin based architecture, so you can check those registry keys and if the desired plugin has executed, you can perform those actions. If needed, we can implement a status cli option, that dumps the executed plugins + state.

Any suggestions or implementations are welcome.

rgl commented 3 years ago

My example VM ended-up with these registry keys/values:

image

The registry key b3d1dc735800195b8f62 seems to be the value of instance-id property that is inside the cidata meta-data json file, is that correct?

From an external viewpoint, how do we known how many plugins exist?

How do we known when all the plugins are "done" (it seems that not all plugins end-up with the same value)?

And how we do this in a way that is not tied with a specific cloud or plugin?

I think we should have a command available in the cloudbase-init package that deals with all this; I can propose one when the questions above are cleared up :-)

For reference, this is what cloud-init returns:

vagrant@example:~$ cloud-init status
status: done
vagrant@example:~$ cloud-init status --wait

status: done
vagrant@example:~$ cloud-init status --wait --long

status: done
time: Mon, 12 Oct 2020 18:05:43 +0000
detail:
DataSourceNoCloud [seed=/dev/sr0][dsmode=net]

This is also described at https://cloudinit.readthedocs.io/en/latest/topics/cli.html#cli-status.

WeetA34 commented 3 years ago

as a workaround, we're using the following powershell:

while ((Select-String -Path 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\cloudbase-init.log' -Pattern '^.+Plugins execution done$') -eq $null) { Write-Host -NoNewLine '.'; Start-Sleep -Seconds 5 }
puetzk commented 2 years ago

See https://github.com/hashicorp/packer/issues/9757#issuecomment-677722423 for another example where cloudbase-init caused a reboot out from underneath provisioning. A cloudbase-init.exe --wait (like cloud-init status --wait) would be very appreciated, much clearer than having scripts that dig around in the implementation details.

roflhouse commented 5 months ago

I just ran into the lack of a wait command as well. I have been trying to use the reg-keys as suggested but have found them Extremely unreliable. To the point of uselessness. I have resorted to looking for specific plugin effects to try and determine if cloudbase-init is done. Like if the computer has been re-named and if the user-data scripts have run. I have seen the keys being written multiple times and i have seen the keys being written before the module has finished.