{"action":"opened","issue":{"url":"https://api.github.com/repos/mitchellh/packer/issues/3829","repository_url":"https://api.github.com/repos/mitchellh/packer","labels_url":"https://api.github.com/repos/mitchellh/packer/issues/3829/labels{/name}","comments_url":"https://api.github.com/repos/mitchellh/packer/issues/3829/comments","events_url":"https://api.github.com/repos/mitchellh/packer/issues/3829/events","html_url":"https://github.com/mitchellh/packer/issues/3829","id":173031146,"number":3829,"title":"Random hangs on \"Startup script not finished yet. Waiting...\" with GCP","user":{"login":"zbjornson","id":469365,"avatar_url":"https://avatars.githubusercontent.com/u/469365?v=3","gravatar_id":"","url":"https://api.github.com/users/zbjornson","html_url":"https://github.com/zbjornson","followers_url":"https://api.github.com/users/zbjornson/followers","following_url":"https://api.github.com/users/zbjornson/following{/other_user}","gists_url":"https://api.github.com/users/zbjornson/gists{/gist_id}","starred_url":"https://api.github.com/users/zbjornson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbjornson/subscriptions","organizations_url":"https://api.github.com/users/zbjornson/orgs","repos_url":"https://api.github.com/users/zbjornson/repos","events_url":"https://api.github.com/users/zbjornson/events{/privacy}","received_events_url":"https://api.github.com/users/zbjornson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-24T18:58:03Z","updated_at":"2016-08-24T18:58:03Z","closed_at":null,"body":"- Packer Version: 0.10.2\r\n- Host platform: Ubuntu 16.04\r\n- Debug log output from `PACKER_LOG=1 packer build template.json` - does not appear to be useful, but I have if needed.\r\n\r\nSomewhere around one in three times, packer gets stuck on \r\n\r\n```\r\n==> googlecompute: Waiting for any running startup script to finish...\r\n==> googlecompute: Startup script not finished yet. Waiting...\r\n==> googlecompute: Startup script not finished yet. Waiting...\r\n...\r\n```\r\n\r\nThis always happens late in my build after several successful connections have already been made and most of the build is done. I don't know exactly when packer starts looking for this relative to running the build steps, but given that the file is called \"step_wait_instance_startup.go\" I would have assumed before the build. :confused:\r\n\r\nI think this is because it's unreliable to rely on the serial port output for this. For all of the failed builds, the serial port output is missing the magic \"Packer startup script done\" text (which is what that step searches for). [Here's a gist with the serial output for one failed and one successful build](https://gist.github.com/zbjornson/d64a30aa9a39911e8a752327a1e68803). (Coincidentally some bytes are missing from the line where the metadata is set.) Another failed one had the magic text interrupted: \r\n\r\n```\r\nAug 24 18:44:28 ubuntu startupscript: Packer startup script starting.\r\nAug 24 18:44:29 ubuntu startupscript: Packer startup script Aug 24 18:44:29 ubuntu systemd[1]: Started Update UTMP about SysAug 24 18:44:30 ubuntu ntpd[2643]: Soliciting pool server 204.2.134.163\r\nAug 24 18:44:30 ubuntu ntpd[2643]: Soliciting pool server 173.255.196.241\r\n```\r\n(missing the \"done.\")\r\n\r\nCould packer instead grep the startup script logs? That's /var/log/daemon.log (Debian, CentOS, RHEL images newer than v20160606) or /var/log/startupscript.log (Ubuntu; images older than v20160606) via ssh? ([docs](https://cloud.google.com/compute/docs/startupscript)) These are correct even when the serial output is not:\r\n\r\n```\r\n[host that is stuck]$ grep \"startup script\" /var/log/startupscript.log\r\nAug 24 18:44:28 ubuntu startupscript: Running startup script /var/run/google.startup.script\r\nAug 24 18:44:28 ubuntu startupscript: Packer startup script starting.\r\nAug 24 18:44:29 ubuntu startupscript: Packer startup script done.\r\nAug 24 18:44:29 ubuntu startupscript: Finished running startup script /var/run/google.startup.script\r\n```"}}
{"actor":{"display_login":"zbjornson"}}