我尝试使用https://github.com/googlecloudplatform/gce-rescue来拯救虚拟机,但是失败并出现以下错误:
test@cloudshell:~ $ gce-rescue --zone us-west2-b --name test-vm
Traceback (most recent call last):
File "gce-rescue", line 8, in <module>
sys.exit(main())
File "/lib/python3.9/site-packages/gce_rescue/bin/rescue.py", line 44, in main
vm = Instance(test_mode=False, **parse_kwargs)
File "<string>", line 12, in __init__
File "/lib/python3.9/site-packages/gce_rescue/gce.py", line 111, in __post_init__
check = Validations(
File "<string>", line 7, in __init__
File "/lib/python3.9/site-packages/gce_rescue/tasks/pre_validations.py", line 48, in __post_init__
authorize_check(project = self.project)
File "/lib/python3.9/site-packages/gce_rescue/tasks/validations/authorization.py", line 43, in authorize_check
result = service.projects().testIamPermissions(
File "/usr/local/lib/python3.9/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/googleapiclient/http.py", line 938, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting
https://cloudresourcemanager.googleapis.com/v1/projects/XXXXX:testIamPermissions?alt=json returned "Cloud Resource Manager API has not been
used in project XXXXX before or it is disabled.
Enable it by visiting https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=XXXXX then retry.
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.".
Details: "[{'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Google developers console API activation',
'url': 'https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=XXXXX'}]},
{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'SERVICE_DISABLED',
'domain': 'googleapis.com',
'metadata': {'service': 'cloudresourcemanager.googleapis.com', 'consumer': 'projects/XXXXX'}}]">
我们怎样才能解决这个问题?
答案1
gce-rescue
工具失败,因为cloudresourcemanager.googleapis.com
项目上未启用 API。
请通过以下方式启用此 APIhttps://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=XXXXX,将 XXXXX 替换为您的 GCP 项目 id,然后重新运行gce-rescue
。
这应该可以解决这个问题。
答案2
关于错误异常,您可以阅读:'reason': 'SERVICE_DISABLED',
在使用 GCE Rescue 之前,请确保您拥有资源管理器API已启用:
$ gcloud services enable cloudresourcemanager.googleapis.com