google / turbinia

Automation and Scaling of Digital Forensics Tools
Apache License 2.0
752 stars 164 forks source link

Catch some GCP auth errors #417

Closed rgayon closed 4 years ago

rgayon commented 5 years ago

When we haven't auth'ed to GCP API, turbinia server and psqlworker will loop with:

Traceback (most recent call last):
  File "/home/romaing/venvs/turbinia-dev3/bin/turbiniactl", line 11, in <module>
    load_entry_point('turbinia==20181004', 'console_scripts', 'turbiniactl')()
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/turbinia-20181004-py3.5.egg/turbinia/turbiniactl.py", line 465, in main
    jobs_blacklist=args.jobs_blacklist, jobs_whitelist=args.jobs_whitelist)
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/turbinia-20181004-py3.5.egg/turbinia/client.py", line 761, in __init__
    self.task_manager.setup(jobs_blacklist, jobs_whitelist)
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/turbinia-20181004-py3.5.egg/turbinia/task_manager.py", line 116, in setup
    self._backend_setup(*args, **kwargs)
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/turbinia-20181004-py3.5.egg/turbinia/task_manager.py", line 397, in _backend_setup
    self.server_pubsub.setup_subscriber()
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/turbinia-20181004-py3.5.egg/turbinia/pubsub.py", line 86, in setup_subscriber
    self.subscriber.create_subscription(subscription_path, self.topic_path)
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/google/cloud/pubsub_v1/_gapic.py", line 40, in <lambda>
    fx = lambda self, *a, **kw: wrapped_fx(self.api, *a, **kw)  # noqa
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/google/cloud/pubsub_v1/gapic/subscriber_client.py", line 398, in create_subscription
    request, retry=retry, timeout=timeout, metadata=metadata
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/google/api_core/retry.py", line 273, in retry_wrapped_func
    on_error=on_error,
  File "/home/romaing/venvs/turbinia-dev3/lib/python3.5/site-packages/google/api_core/retry.py", line 208, in retry_target
    time.sleep(sleep)
KeyboardInterrupt

it would be nice to have a check that we can auth to GCP, and get a specific error message

aarontp commented 5 years ago

Yeah, this is related to this: https://github.com/google/turbinia/issues/432

We trap these kinds of errors in some places but not others, so we need to make sure we do that everywhere.

aarontp commented 4 years ago

I believe this is fixed now: https://github.com/google/cloud-forensics-utils/blob/06d1367f0ac43d6af6248cbf56e11d1f70f4044d/libcloudforensics/gcp.py#L1100