Google-cloud-python: DNS: zone exist endpoint has changed?

Created on 17 Aug 2018  路  9Comments  路  Source: googleapis/google-cloud-python

  1. internal image based on python:3.6.3
  2. 3.6.3
  3. dns version 0.29.0
>>> from google.cloud import dns
>>> self.client = dns.Client(project='PROJECT_ID')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'self' is not defined
>>> client = dns.Client(project='PROJECT_ID')
>>> client.zone('zone_name', 'dns_name.com')
<google.cloud.dns.zone.ManagedZone object at 0x7f8285fac5f8>
>>> client.zone('zone_name', 'dns_name.com').exists()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/google/cloud/dns/zone.py", line 285, in exists
    query_params={'fields': 'id'})
  File "/usr/local/lib/python3.6/site-packages/google/cloud/_http.py", line 293, in api_request
    raise exceptions.from_http_response(response)
google.api_core.exceptions.BadRequest: 400 GET https://www.googleapis.com/dns/v1/projects/PROJECT_ID/managedZones/zone_name?fields=id: Request contains an invalid argument.
  1. See stacktrace

I've been running this exist call on this zone and dns name for a few months now. Suddenly we are getting this breakage. I've check that the zone and dns exist in Cloud Console. Though you'd think either way it would return a better error? I've also checked that this isn't a new dns module version.

question dns backend

Most helpful comment

Is there any update on this? I'm always getting true for zone.exists(), regardless of what I give for name and dns name

>>> zone = client.zone('pizza', 'hotdog')
>>> print(zone.exists())
True
>>> wat..

All 9 comments

it looks like https://cloud.google.com/dns/api/v1/managedZones/get doesn't even accept a query param as https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/dns/google/cloud/dns/zone.py#L284 is trying to pass?

it's unclear to me if the api/v1 changed recently?

I am also experiencing the exact issue with exist

Traceback (most recent call last):
  File "/usr/bin/kcli", line 11, in <module>
    load_entry_point('kcli', 'console_scripts', 'kcli')()
  File "/src/kcli/kvirt/cli.py", line 1239, in cli
    args.func(args)
  File "/src/kcli/kvirt/cli.py", line 650, in plan
    overrides=overrides, info=info)
  File "/src/kcli/kvirt/config.py", line 1136, in plan
    files=files, enableroot=enableroot, overrides=overrides, tags=tags)
  File "/src/kcli/kvirt/gcp/__init__.py", line 215, in create
    self.reserve_dns(name, nets=nets, domain=domain, alias=alias)
  File "/src/kcli/kvirt/gcp/__init__.py", line 700, in reserve_dns
    if not zone.exists():
  File "/usr/lib/python3.6/site-packages/google/cloud/dns/zone.py", line 285, in exists
    query_params={'fields': 'id'})
  File "/usr/lib/python3.6/site-packages/google/cloud/_http.py", line 293, in api_request
    raise exceptions.from_http_response(response)
google.api_core.exceptions.BadRequest: 400 GET https://www.googleapis.com/dns/v1/projects/PROJECT/managedZones/DNS?fields=id: Request contains an invalid argument.

cc: @karmab

@theacodes, @crwilcox please loop in the appropriate PoC for the Cloud DNS API.

Hi All. I spoke with some members of the DNS team. This was a regression. The team has identified the issue and is working on a fix. We expect that by next week a release will occur to prod to resolve your problem.

Thanks! Will there be an update when the release happens?

Is there any update on this? I'm always getting true for zone.exists(), regardless of what I give for name and dns name

>>> zone = client.zone('pizza', 'hotdog')
>>> print(zone.exists())
True
>>> wat..

@crwilcox ping?

Experiencing the same problem as @AlecTroemel . exists() always returns True even on non-existing zones.
An additional remark:
The implementation seems "opinionated" ( https://github.com/googleapis/google-cloud-python/blob/feed53690af6eb03408a1f67107196fc701f8a80/dns/google/cloud/dns/zone.py#L286-L289 )

@UnsignedLong ManagedZone.exists() returns False if the GET request raises a 404 NOT_FOUND error. The issue here seems to be that the back end is not returning a 404 when it should be.

@UnsignedLong I'm not sure what you mean by "the implementation seems opinionated."

Was this page helpful?
0 / 5 - 0 ratings