Eu tentei usarhttps://github.com/googlecloudplatform/gce-rescuepara resgatar uma VM, porém falhou com o erro abaixo:
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'}}]">
Como podemos corrigir esse problema?
Responder1
gce-rescue
ferramenta falhou porque a cloudresourcemanager.googleapis.com
API não está habilitada no projeto.
Ative esta API viahttps://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=XXXXX, substituindo XXXXX pelo ID do projeto do GCP e execute novamente o arquivo gce-rescue
.
Isso deve resolver o problema.
Responder2
Na exceção de erro você pode ler:'reason': 'SERVICE_DISABLED',
Antes de usar o GCE Rescue, certifique-se de ter oAPI do gerenciador de recursoshabilitado:
$ gcloud services enable cloudresourcemanager.googleapis.com