-
Notifications
You must be signed in to change notification settings - Fork 492
GCLOUD: inserting new zones in dnsconfig blocks changes on subsequent zones #2479
Copy link
Copy link
Closed
Labels
Description
Describe the bug
GCLOUD: new zones inserted in the dnsconfig above existing zones using the same GCLOUD provider block (and cause errors for) subsequent changes when running 'dnscontrol push'
To Reproduce
Steps to reproduce the behavior:
- An existing dnsconfig and empty zones created in the GCLOUD account:
var DNS_GOOGLE = NewDnsProvider('gcloud');
D('atestdomain0.com', REG_NONE, DnsProvider(DNS_GOOGLE),
NAMESERVER_TTL('21600')
);
D('atestdomain1.com', REG_NONE, DnsProvider(DNS_GOOGLE),
NAMESERVER_TTL('21600')
);
D('atestdomain2.com', REG_NONE, DnsProvider(DNS_GOOGLE),
NAMESERVER_TTL('21600')
);
- Modify the dnsconfig with changes for the existing zones, and insert NEW zones in the config:
var DNS_GOOGLE = NewDnsProvider('gcloud');
var RECORDS = [
A('test', '127.0.0.1')
]
D('atestdomain0.com', REG_NONE, DnsProvider(DNS_GOOGLE),
NAMESERVER_TTL('21600'),
RECORDS
);
D('insert-atestdomain0.com', REG_NONE, DnsProvider(DNS_GOOGLE),
NAMESERVER_TTL('21600'),
RECORDS
);
D('atestdomain1.com', REG_NONE, DnsProvider(DNS_GOOGLE),
NAMESERVER_TTL('21600'),
RECORDS
);
D('atestdomain2.com', REG_NONE, DnsProvider(DNS_GOOGLE),
NAMESERVER_TTL('21600'),
RECORDS
);
- Run 'dnscontrol preview'
$ dnscontrol preview
[INFO: Diff2 algorithm in use. Welcome to the future!]
******************** Domain: atestdomain0.com
1 correction (gcloud)
#1: + CREATE A test.atestdomain0.com 127.0.0.1 ttl=300
******************** Domain: insert-atestdomain0.com
WARNING: Zone 'insert-atestdomain0.com' does not exist in the 'gcloud' profile and will be added automatically.
WARNING: No nameservers declared; skipping registrar. Add {no_ns:'true'} to force.
******************** Domain: atestdomain1.com
1 correction (gcloud)
#1: + CREATE A test.atestdomain1.com 127.0.0.1 ttl=300
******************** Domain: atestdomain2.com
1 correction (gcloud)
#1: + CREATE A test.atestdomain2.com 127.0.0.1 ttl=300
Done. 3 corrections.
- run 'dnscontrol push'
$ dnscontrol push
[INFO: Diff2 algorithm in use. Welcome to the future!]
******************** Domain: atestdomain0.com
1 correction (gcloud)
#1: + CREATE A test.atestdomain0.com 127.0.0.1 ttl=300
SUCCESS!
******************** Domain: insert-atestdomain0.com
Adding zone for insert-atestdomain0.com to gcloud account
ERROR: ERROR: domain "insert-atestdomain0.com" not found in your GCLOUD account
******************** Domain: atestdomain1.com
Adding zone for atestdomain1.com to gcloud account
WARNING: Error creating domain: googleapi: Error 409: The resource 'entity.managedZone' named 'zone-atestdomain1-com' already exists, alreadyExists
WARNING: No nameservers declared; skipping registrar. Add {no_ns:'true'} to force.
******************** Domain: atestdomain2.com
Adding zone for atestdomain2.com to gcloud account
WARNING: Error creating domain: googleapi: Error 409: The resource 'entity.managedZone' named 'zone-atestdomain2-com' already exists, alreadyExists
WARNING: No nameservers declared; skipping registrar. Add {no_ns:'true'} to force.
Done. 1 corrections.
Expected behavior
Any inserted domain should be created and all changes in dnsconfig should be executed:
$ dnscontrol push
[INFO: Diff2 algorithm in use. Welcome to the future!]
******************** Domain: atestdomain0.com
1 correction (gcloud)
#1: + CREATE A test.atestdomain0.com 127.0.0.1 ttl=300
SUCCESS!
******************** Domain: insert-atestdomain0.com
Adding zone for insert-atestdomain0.com to gcloud account
1 correction (gcloud)
#1: + CREATE A test.insert-atestdomain0.com 127.0.0.1 ttl=300
SUCCESS!
******************** Domain: atestdomain1.com
1 correction (gcloud)
#1: + CREATE A test.atestdomain1.com 127.0.0.1 ttl=300
SUCCESS!
******************** Domain: atestdomain2.com
1 correction (gcloud)
#1: + CREATE A test.atestdomain2.com 127.0.0.1 ttl=300
SUCCESS!
Done. 4 corrections.
DNS Provider
- GCLOUD
Additional context
EnsureZoneExists is currently resetting the cache and discarding the *ManagedZone returned during zone creation. I'm uncertain of the intent of this.
dnscontrol/providers/gcloud/gcloudProvider.go
Lines 373 to 374 in 31bf652
| g.zones = nil // reset cache | |
| _, err = g.client.ManagedZones.Create(g.project, mz).Do() |
I have a proposed fix and will submit a PR with additional changes
Reactions are currently unavailable