startup-script added to an instance in GCP doesn't seem to run on first boot (but does on subsequent boots)
I'm using the
https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-7-v20160921 base image but had the same issue on a slightly older version of the centos-7 image too.
This happens whether I use the API to create an instance, or the web console.
According to the docs (https://cloud.google.com/compute/docs/startupscript) adding a metadata with the key
startup-script and value of a script should cause the script to be run on every boot.
(There is a section about adding the script to a running instance, and it mentions that a reboot is required to get the script to run, but this (apparently) shouldn't apply to new instances.)
It's possible to force the script to run using
sudo google_metadata_script_runner --script-type startup (https://cloud.google.com/compute/docs/startupscript#rerunthescript) which implies that the script is loaded, but just not run, so I'm not sure what's going on.
Am I doing something wrong, or have I found a bug in GCP? :)