In Google Compute Engine, when starting a virtual machine, an operation is created. When the operation is done, the virtual machine is ready (or the operation could have a failed status).
However, my startup script (specified via startup-script-url
) is still running after a successful insert operation.
Is there a way to detect using the compute api?
I'm using the googleapis
node library which is basically a wrapper around the official Compute Api (https://developers.google.com/apis-explorer/#p/compute/v1/).
When I'm doing this manually, I just keep an eye on the serial console.
Startup scripts stored locally or added directly execute before startup scripts that are stored in Cloud Storage. The type of file containing the script also impacts the order of execution. The following table shows, based on the metadata key, the order of execution of Windows startup scripts.
During the boot process the init process looks in the /etc/inittab file to find the default runlevel. Having identified the runlevel it proceeds to execute the appropriate startup scripts located in the /etc/rc. d sub-directory.
Stay organized with collections Save and categorize content based on your preferences. A startup script is a file that contains commands that run when a virtual machine (VM) instance boots.
Not sure if this would work, but you could let your startup script add a tag to its host once it's done: https://cloud.google.com/sdk/gcloud/reference/compute/instances/add-tags
Then you could poll calls to describe
:
https://cloud.google.com/sdk/gcloud/reference/compute/instances/describe
Once you see the tag added there your script should be done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With