mozilla/frost

Handle disabled APIs for GCP

ajvb opened this issue · 1 comments

ajvb commented

If APIs are disabled in GCP, tests will currently error out like so:

==================================== ERRORS ====================================
___ ERROR collecting frost/gcp/sql/test_sql_instance_private_ip_required.py ____
gcp/sql/test_sql_instance_private_ip_required.py:8: in <module>
    "sql_instance", instances(), ids=lambda instance: instance["name"]
gcp/sql/resources.py:5: in instances
    return gcp_client.list("sqladmin", "instances", version="v1beta4")
gcp/client.py:90: in list
    self._list(product, subproduct, version, results_key, call_kwargs)
gcp/client.py:112: in _list
    results = self._get_list_results(
gcp/client.py:149: in _get_list_results
    results = self._list_all_items(api_entity, call_kwargs, results_key)
gcp/client.py:159: in _list_all_items
    resp = request.execute()
venv/lib/python3.8/site-packages/oauth2client/_helpers.py:133: in positional_wrapper
    return wrapped(*args, **kwargs)
venv/lib/python3.8/site-packages/googleapiclient/http.py:838: in execute
    raise HttpError(resp, content, uri=self.uri)
E   googleapiclient.errors.HttpError: <HttpError 403 when requesting https://sqladmin.googleapis.com/sql/v1beta4/projects/<projectname>/instances?alt=json returned "Cloud SQL Admin API has not been used in project XXXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=XXXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">

I'm not sure if this is desired. It might be preferable to print a descriptive message and instead skip the test. AIUI if an API is disabled like so, then it can be assumed that there are no resources to test.

ajvb commented

Fixed with #361