Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on 0.60/0.61 if Compute Engine API not enabled #71

Open
qgallet opened this issue Jun 30, 2023 · 2 comments
Open

Crash on 0.60/0.61 if Compute Engine API not enabled #71

qgallet opened this issue Jun 30, 2023 · 2 comments

Comments

@qgallet
Copy link

qgallet commented Jun 30, 2023

This was working fine on 0.59. When running gcpdiag on a project that hasn't enabled Compute Engine API, an exception is raised and cannot be bypassed, even if I try to exclude all GCE rules.

$ gcpdiag lint --project=myproject --exclude=gce

gcpdiag 🩺  0.61

Starting lint inspection (project: myproject)...

   ... fetching metadata of project myproject

Traceback (most recent call last):
  File "/opt/gcpdiag/gcpdiag/queries/gce.py", line 763, in get_project_metadata
    response = query.execute(num_retries=config.API_RETRIES)
  File "/opt/gcpdiag/.venv/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/opt/gcpdiag/.venv/lib/python3.9/site-packages/googleapiclient/http.py", line 938, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://compute.googleapis.com/compute/v1/projects/myproject?alt=json returned "Compute Engine API has not been used in project 1234567890 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=1234567890 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.". Details: "[{'message': 'Compute Engine API has not been used in project 1234567890 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=1234567890 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.', 'domain': 'usageLimits', 'reason': 'accessNotConfigured', 'extendedHelp': 'https://console.developers.google.com'}]">

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/gcpdiag/bin/gcpdiag", line 70, in <module>
    main(sys.argv)
  File "/opt/gcpdiag/bin/gcpdiag", line 43, in main
    lint_command.run(argv)
  File "/opt/gcpdiag/gcpdiag/lint/command.py", line 342, in run
    if not gce.is_project_serial_port_logging_enabled(context.project_id) and \
  File "/opt/gcpdiag/gcpdiag/queries/gce.py", line 959, in is_project_serial_port_logging_enabled
    value = get_project_metadata(
  File "/opt/gcpdiag/gcpdiag/caching.py", line 155, in _cached_api_call_wrapper
    result = func(*args, **kwargs)
  File "/opt/gcpdiag/gcpdiag/queries/gce.py", line 765, in get_project_metadata
    raise utils.GcpApiError(err) from err
gcpdiag.utils.GcpApiError: Compute Engine API has not been used in project 1234567890 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=1234567890 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
@schweikert
Copy link
Collaborator

Thanks for reporting this. I updated the default version to be again 0.59 and we will work on a fix.

@ropeck
Copy link
Collaborator

ropeck commented Jul 31, 2023

the current version 0.63 includes a fix to prevent an exception when Compute Engine API is not enabled.
Before closing this issue, can you check to confirm that it resolves your environment as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants