gce-rescue 未能救援 GCP 實例

gce-rescue 未能救援 GCP 實例

我嘗試使用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

相關內容