2

we have a startup-script that is working fine, but it only gets executed after reboot.

i'm updating gcutil to gcloud compute and centos6 to centos7.

I'm not sure if this has something to do with security issues (SElinux?).

Can someone please help me debugging this?

Facts: There startup-script log doesn't exist at instance creation. Also, in output console it says that there is no startup-scripts.

After rebooting, everything goes how it should.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
brdido
  • 351
  • 1
  • 3
  • 12
  • Just found this in Serial Console: `localhost run-startup-scripts: ... curl: (6) Could not resolve host: metadata.google.internal; Unknown error` – brdido Feb 09 '15 at 20:11
  • And after some seconds the following : `NetworkManager[563]: startup complete` Is my instance querying for metadata before network manager starts? How do I solve this? – brdido Feb 09 '15 at 20:14

2 Answers2

2

Editing /usr/share/google/run-startup-scripts to sleep for 30 seconds works.

Just add :

sleep 30 (You may also try lower intervals)

It is an immediate answer for the problem but it is far from being the real solution.

My clues and how I got here are im my comments

brdido
  • 351
  • 1
  • 3
  • 12
0

If I am not mistaking, the startup script executes only on system startup/reboot, so this should work as expected. Script gets executed after the machine is restarted. How are you passing it to the metadata server ? is it startup-script, startup-script-url, from GCS bucket ? I have seen "centos-7-v20141016" having issues processing startup scripts.

Marius I
  • 1,461
  • 12
  • 13
  • Hi Marius, thank you for answering. i'm using startup-script from file (and i can see the full script in metadata). But i've entered here because it has something to do with SElinux. I'm not sure yet the details of the issue, apparently some rule taking too long to be configured maybe? Disabling SElinux worked, and i'm blocking access through firewall. – brdido Feb 11 '15 at 17:13
  • It happened again @marius, nothing has changed... I have no idea why sometimes it happens... I can't put this in production. – brdido Feb 12 '15 at 12:47
  • First I would suggest you to use centos-7-v20150127 or centos-6-v20150127 if you have not tried that yet. Another thing to try is setting a delay/sleep in your script for a few seconds in case a rule is taking too long to be configured as you have mentioned. Lastly, can you try and run the script from a GCS bucket ? startup-script-url – Marius I Feb 16 '15 at 05:57
  • Thanks Marius. Trying to use the script from GCS bucket didn't work. I will try centos-7-v20150127 and get back to you. – brdido Feb 19 '15 at 13:49
  • Just one detail : if I run `sudo /usr/share/google/run-startup-scripts` it works (or rebooting the VM). – brdido Feb 19 '15 at 13:51
  • Hi Marius, it's happening with centos-7-v20150127. – brdido Feb 25 '15 at 14:50
  • So, i went through google-startup scripts. I 've found that for getting metadata the scripts queries for : `curl http://169.254.169.254/computeMetadata/v1/project/startup-script -H "Metadata-Flavor: Google" -s -w %{http_code}` The first time the instance is initiated i get the following response: `

    The requested URL /computeMetadata/v1/project/startup-script was not found on this server. That’s all we know.` After rebooting the same curl returns: `1352048572200` (i've ommited some numbers here).

    – brdido Feb 25 '15 at 19:33
  • I have altered /usr/share/google/run-startup-scripts to sleep 30 seconds before it actually starts. It seems that this work-around worked. At least for 10 attemptives 100% of the scripts were automatically started after the initial boot of new instances. – brdido Feb 25 '15 at 21:36