Skip to content

Fix DNS driver API inconsistencies - #2233

Open
micafer wants to merge 60 commits into
trunkfrom
dns-consistent-api
Open

micafer wants to merge 60 commits into
trunkfrom
dns-consistent-api

Conversation

@micafer

@micafer micafer commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Fix DNS driver API inconsistencies

Description

Moved from: #2066
Implement #2065

Summary

In general, commit messages provide necessary background regarding the changes made and why.

  • Drop Zerigo DNS
  • Deprecate outdated DNSimple DNS driver
  • Deprecate outdated RcodeZero DNS driver
  • Add unittest API request checking to remaining drivers
  • Add and leverage common code for domain/host name manipulation
  • Add and leverage common code for <type>[:<name>]-style record IDs
  • Change Record.id format for NS1 and Zonomi providers
  • Change Record.id interpretation for World Wide DNS

Status

  • Ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

Aaron Sierra added 30 commits November 13, 2026 15:16
The Zerigo DNS service was permanently shut down on April 30, 2017.
The RcodeZero v1 API has been shutdown:
    https://my.rcodezero.at/openapi/
Enable unit tests to verify HTTP requests they submit.
* Fix test_create_zone_success
* Fix test_get_record_success
* Fix test_update_zone
Leverage the existing get_record.json for this test.
Previously, test_get_record_success() succeeded when receiving a record
completely unrelated to the originating .get_record() request. Update
the request to align with the expected response.
Previously, test_list_records_success() succeeded when receiving records
completely unrelated to the originating .list_records() request. Update
the request to align with the expected response.
Add .hostname(), .fqdn(), and .prefix() helpers to the Zone class. Each
of these functions accepts a host prefix, complete name (unrooted
hostname), or FQDN (rooted hostname) associated with the Zone object and
returns the format implied by the function name.
Add .to_default_id() and .from_default_id() functions to the DNSDriver
class. These functions support the <type>[:<name>] (e.g. "A:www") record
ID format used by many of the drivers.
Previously, our NsOneDNSDriver.get_record() function performed lookups
using a `record_id` format that differed from the ID embedded within the
returned Record instance, so the driver leveraged two independent
record ID concepts simultaneously.

The NS1 API returns an ID when records are created, but that ID has no
local relevance. For example, it cannot be used to request the record
from the NS1 API.

Make the Record class .id value consistent between create_record() and
get_record(z.id, r.id).

	 |  zone_id |   z.id   |     r.id      |   record_id   |
---------|----------|----------|---------------|---------------|
previous | z.domain |  random* |    random*    |     r.type    |
    next | z.domain | z.domain | r.type:r.name | r.type:r.name |

* no meaning, effectively random
* Fix TTL in test_create_record_success() request
* Align record update with parent zone in test_update_record_success()
* Fix record_id in test_get_record_success() request
DNS AAAA records are associated with IPv6 addresses.
* Fix "ttle" typo in test_update_record()
The update_record() and delete_record() functions require a Record
instance in their respective argument lists to identify the DNS record
to manipulate. Record objects instantiated by this driver contain the
assocated "slot" ID within the .id field, so:

1. There is no need for the user to specify the "slot" ID via
   .update_record(..., extra={"entry": ID}). However, since it was
   previously required, an "entry" key will be accepted as long as it is
   consistent with the Record instance.
2. There is no need for .delete_record() to search the Record's zone for
   the "slot" ID of the Record.
Aaron Sierra and others added 21 commits November 13, 2026 15:39
Previously, the Zonomi DNS driver could only return the first record
for a given host, because it used the name of the host as Record.id.

Now, use the new default, <type>[:<name>], format to allow various
records to be differentiated for a given host.
DNS drivers share the need to manipulate host/domain names, so let's add
utility functions to the common Record and Zone classes to allow
redundant code scattered throughout the various drivers to be
consolidated into common and consistent implementations.

  * Record.name - no longer driver-dependent, now the host prefix or ""
  * Record.hostname - the complete host name, including domain part
  * Record.fqdn - the fully qualified domain name, including root dot

  * Zone.domain - no longer driver-dependent, now the unrooted domain
  * Zone.rooted() - format a (un)rooted domain as a rooted domain
  * Zone.unrooted() - format a (un)rooted domain as an unrooted domain
Update testing inputs to conform to spec'ed usage.
Leverage common code from DNSDriver, Record, and Zone classes for host
name and record ID handling.
Drop RackspaceDNSDriver._to_partial_record_name() and
RackspaceDNSDriver._to_full_record_name() in favor of the common
support provided by the Record and Zone classes.
@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.18100% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.80%. Comparing base (f89932e) to head (908dd88).

Files with missing lines Patch % Lines
libcloud/dns/drivers/worldwidedns.py 36.36% 4 Missing and 3 partials ⚠️
libcloud/dns/drivers/route53.py 75.00% 2 Missing ⚠️
libcloud/dns/drivers/google.py 66.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #2233      +/-   ##
==========================================
- Coverage   83.07%   82.80%   -0.27%     
==========================================
  Files         343      341       -2     
  Lines       78661    79238     +577     
  Branches     8587     8570      -17     
==========================================
+ Hits        65345    65613     +268     
- Misses      10588    10930     +342     
+ Partials     2728     2695      -33     
Files with missing lines Coverage Δ
libcloud/dns/base.py 98.08% <100.00%> (+0.80%) ⬆️
libcloud/dns/drivers/auroradns.py 75.89% <100.00%> (+2.35%) ⬆️
libcloud/dns/drivers/dnsimple.py 26.44% <ø> (-67.82%) ⬇️
libcloud/dns/drivers/durabledns.py 88.14% <100.00%> (+0.08%) ⬆️
libcloud/dns/drivers/gandi.py 92.25% <100.00%> (+0.06%) ⬆️
libcloud/dns/drivers/gandi_live.py 89.06% <100.00%> (+0.06%) ⬆️
libcloud/dns/drivers/luadns.py 88.18% <100.00%> (ø)
libcloud/dns/drivers/nsone.py 76.47% <100.00%> (+0.79%) ⬆️
libcloud/dns/drivers/pointdns.py 86.33% <100.00%> (ø)
libcloud/dns/drivers/powerdns.py 67.47% <100.00%> (+0.40%) ⬆️
... and 35 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@micafer micafer mentioned this pull request Nov 20, 2026
2 of 4 tasks
@micafer
micafer requested a review from tisonkun November 20, 2026 12:07
@micafer micafer mentioned this pull request Nov 20, 2026
4 of 7 tasks

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DNS suite passes locally. I reproduced the name-handling issues below with mocked provider responses.

Comment thread libcloud/dns/base.py
Return the traditional fully qualified domain name, including full-stop
trailing dot, for this record.
"""
return self.zone.fqdn(self.name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In zone example.com, deleting example.com.example.com. through Google Cloud DNS sends a deletion for example.com.. self.name is already relative. Please build the FQDN without stripping the suffix a second time and check that the record ID round-trips too.

id = ":".join((self.RECORD_TYPE_MAP[type], name))
record = Record(
id=id,
id=self.to_default_id(zone, name, type),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list_records() raises ZoneNotRelatedError for an AWS response containing www.example.com.. The slice at line 570 leaves www. now that zone.domain has no trailing dot. Please pass the full name through and cover a dotted name in the fixture.

"rrsets": [
{
"name": name,
"name": hostname,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With api_version="v1" (PowerDNS 4), creating or updating www.example.com. sends www.example.com, and deleting it sends just www. Please send the rooted FQDN for all three v4 operations and the full hostname for v3 deletes. PowerDNS request examples

self.assertEqual(sent.method, "PUT")
self.assertEqual(sent.url, f"/client/v4/zones/{zone.id}/dns_records/{record.id}")
self.assertEqual(sent.json["type"], "A")
self.assertEqual(sent.json["name"], "test6")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also cover an update that omits name. With the existing apex A record, record.update(data="192.0.2.2") sends "name": "". Cloudflare requires the full record name, so the PUT should carry example.com.

from libcloud.dns.drivers.rcodezero import RcodeZeroDNSDriver


@unittest.skip("v1 API is deprecated")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The driver already defaults to /api/v2, and this class uses v2 fixtures. All 15 tests pass locally with the skip removed. Please keep the v2 driver and its tests enabled and limit the deprecation to v1.

Comment thread libcloud/dns/base.py
if name == domain:
return ""

if name.endswith(f".{domain}"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For zone example.com, zone.prefix("www.EXAMPLE.COM.") raises ZoneNotRelatedError. Please compare the zone labels case-insensitively for both apex and suffix matches, while preserving the original prefix.

extra["priority"] = priority
return Record(
id="{}:{}".format(data["rrset_type"], data["rrset_name"]),
id=self.to_default_id(zone, data["rrset_name"], data["rrset_type"]),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing Gandi apex fixture has rrset_name="@", so record.fqdn becomes @.example.com.. Please map @ to the empty relative name on read and back to @ when sending an apex request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants