how to get error if starting compute engine instance fails

泪湿孤枕 提交于 2019-12-05 05:56:08

I actually didn't observe the error you described using GCE yet, but to get the "error state" of a GCE instance, you could query the Compute API with Method: instances.get and evaluate the response for "status" and "statusMessage"

HTTP request
GET https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{resourceId}

The return values for status may be one of the following: PROVISIONING, STAGING, RUNNING, STOPPING, STOPPED, SUSPENDING, SUSPENDED, and TERMINATED.

See also the reference manual for this API Call: https://cloud.google.com/compute/docs/reference/rest/v1/instances/get

So if you query the status of your newly created GCE instance for some time, and only return with "success" if the status of the instance switched from "PROVISIONING" or "STAGING" to "RUNNING", you should be safe. I never observed that there were any errors during instance creation, if the instance status was set to "RUNNING".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!