Skip to content

fixing dns server delete record in all roles#253

Open
danlavu wants to merge 8 commits into
SSSD:masterfrom
danlavu:ipv6
Open

fixing dns server delete record in all roles#253
danlavu wants to merge 8 commits into
SSSD:masterfrom
danlavu:ipv6

Conversation

@danlavu

@danlavu danlavu commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The dig query is insufficient because it may be cached, failing when called because it attempts to delete a record that doesn't exist in the zone.

The method logic, at a high level, goes like this: because we pass in one parameter, we need to resolve the IP address from the hostname, which may return multiple addresses. We then iterate through the zones to determine the type of record. There may be a case where the A record is deleted, but still needs to iterate through because the PTR record exists. Then we determine if it's an IPv4 or IPv6 address. Each type of record requires a different argument to delete it properly, and then there is a lot of formatting required.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the DNS record deletion logic across the Active Directory, FreeIPA, and Samba roles to query and delete records directly using provider-specific tools rather than relying on generic dig commands, and adds IPv6 support to the network device utility. However, the refactored deletion logic introduces several critical issues that must be addressed: multiple potential TypeError exceptions from slicing or checking None values, a logic inversion in Samba where deletion only occurs if no records are found, an AttributeError on self.zone, a typo in raise_on_error, and several Python runtime errors in FreeIPA (such as calling the non-existent trim() method and unpacking errors).

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread sssd_test_framework/roles/ipa.py Outdated
Comment thread sssd_test_framework/roles/samba.py Outdated
Comment thread sssd_test_framework/roles/ad.py Outdated
Comment thread sssd_test_framework/roles/ad.py
Comment thread sssd_test_framework/roles/samba.py Outdated
Comment thread sssd_test_framework/roles/samba.py Outdated
Comment thread sssd_test_framework/roles/ipa.py Outdated
@danlavu danlavu force-pushed the ipv6 branch 4 times, most recently from 86b2135 to d96150a Compare June 18, 2026 02:34
@danlavu danlavu changed the title dyndns - inprogress fixing dns server delete record in all roles Jun 18, 2026
@alexey-tikhonov alexey-tikhonov requested a review from thalman June 18, 2026 12:45
@alexey-tikhonov alexey-tikhonov requested a review from spoore1 June 18, 2026 12:46
Comment thread sssd_test_framework/utils/network.py Outdated

def add_device(self, ip: str, netmask: str = "255.255.255.0") -> IPUtils:
def add_device(
self, ip: str, netmask: str = "255.255.255.0", ipv6: str | None = None, prefix: str = "64"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really do not like that we have different way to specify netmask for IPv4 and 6.

is is too late to change netmask to prefix and prefix to prefix6?

in my opinion it would be better to have it in connected string like:

add_device(self, ip: str, ipv6: str | None = None) where ip can be 1.2.3.4/24 or 1.2.3.4/255.255.255.0 and ipv6 can be like cafe::1/64. We can easily detect that "/" is missing and provide default for it.

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can change that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated, str or list, so we can link multiple ips to the device.

@thalman thalman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looks good. See my question about add_device.

@danlavu danlavu force-pushed the ipv6 branch 7 times, most recently from 08891e8 to a5bc137 Compare June 25, 2026 17:31

@spoore1 spoore1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looks good and from testing it's working. I have a few nit-picks (optional mostly) and one actual question about the version pinning for pytest-mh.

Comment thread sssd_test_framework/roles/ad.py Outdated

If dig returns a result, iterate through the zones, if the zone is in the name, it's a forward record.
The return may be from the cache, search the zone for the record, if found, delete it. If "in-addr" is
in the zone name, it's a reverse record then follows the same steps as a forward record.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit-pick: the phrasing with the word then here sounds slightly off to me:
If "in-addr" is in the zone name, it's a reverse record then follows the same steps
Is this closer to the intent:
If "in-addr" is in the zone name, it's a reverse record and should follow the same steps
or more like this:
If "in-addr" is in the zone name, it's a reverse record that follows the same steps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, that

Comment thread sssd_test_framework/roles/ad.py Outdated
if records is not None:
for zone in zones:
if zone in name:
a_record = self.host.conn.run(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

since you have to loop through a potential list of a records returned here, would it make more sense for the variable to be named a_records and change the for below from:
for j in a_record:
to:
for a_record in a_records:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does make sense, fixed.

Comment thread requirements.txt
pytest
python-ldap
pytest-mh >= 1.0.29
pytest-mh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this temporary? I believe we want it pinned to a minimum version don't we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea, I'm not sure what is going on. IDMCI is failing because sssd-test-framework has a conflicting version, which shouldn't be an issue since it's version 1.0.3 , needs further investigation.

@danlavu danlavu force-pushed the ipv6 branch 2 times, most recently from 1702860 to 05fda02 Compare June 27, 2026 23:04
@danlavu

danlavu commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

I have to redo the entire ipa logic because it was only returning one record. Looking back on this, knowing how complex it is now, I would have added more methods to find the record, get the record, etc. It may be beneficial if the look-up is faster than the dig. I think this will work in the interim.

@danlavu

danlavu commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Increasing the retry/delay to a total of 120 seconds, from the run in IDMCI.

2026-06-28T00:06:39 =========================== short test summary info ============================
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_true (ad)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_false (ad)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0] (ad)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0, dummy0] (ad)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_over_tcp_only (ad)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = None] (ad)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_does_not_contain_use_after_free_bugs (ad)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_true (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_false (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0] (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0, dummy0] (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_configured_ttl_value (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_over_tcp_only (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = None] (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = GSS-TSIG] (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_does_not_contain_use_after_free_bugs (ipa)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_true (samba)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_false (samba)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0] (samba)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0, dummy0] (samba)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_configured_ttl_value (samba)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_over_tcp_only (samba)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = None] (samba)
2026-06-28T00:06:39 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_does_not_contain_use_after_free_bugs (samba)
2026-06-28T00:06:39 FAILED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_configured_ttl_value (ad) - AssertionError: Host client.ad-n9v8.test was not found!
2026-06-28T00:06:39 assert None
2026-06-28T00:06:39 FAILED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = GSS-TSIG] (ad) - AssertionError: Host client.ad-n9v8.test was not found!
2026-06-28T00:06:39 assert None
2026-06-28T00:06:39 FAILED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = GSS-TSIG] (samba) - AssertionError: Host client.samba.test was not found!
2026-06-28T00:06:39 assert None
2026-06-28T00:06:39 ==== 3 failed, 24 passed, 932 deselected, 9 warnings in 1477.30s (0:24:37) =====

@danlavu

danlavu commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

working in idmci


2026-06-28T06:11:05 =========================== short test summary info ============================
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_true (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_false (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0] (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0, dummy0] (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_configured_ttl_value (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_over_tcp_only (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = None] (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = GSS-TSIG] (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_does_not_contain_use_after_free_bugs (ad)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_true (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_false (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0] (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0, dummy0] (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_configured_ttl_value (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_over_tcp_only (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = None] (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = GSS-TSIG] (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_does_not_contain_use_after_free_bugs (ipa)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_true (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_is_set_to_false (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0] (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_with_address_filtering[dyndns_iface = eth0, dummy0] (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_configured_ttl_value (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_over_tcp_only (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = None] (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_authentication_mechanism[dyndns_auth = GSS-TSIG] (samba)
2026-06-28T06:11:05 PASSED ../sssd/src/tests/system/tests/test_dyndns.py::test_dyndns__update_does_not_contain_use_after_free_bugs (samba)
2026-06-28T06:11:05 ========= 27 passed, 932 deselected, 2 warnings in 1151.41s (0:19:11) ==========

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants