#8196 API: dnsrecord_del failure with empty list aaaarecord
Closed: fixed 4 years ago by abbra. Opened 4 years ago by twoerner.

Issue

dnsrecord_add API call allows to use an empty list for aaaarecord and succeessfully adds the IPv4 addresses from arecord list. Using the same to remove the IPv4 addresses again with dnsrecord_del leads to an error.

Adding the IPv4 addresses with:

api.Command["dnsrecord_add"](domain,
                             **{
                                 'idnsname': host_name,
                                 'arecord': ['192.168.100.100',
                                             '192.168.100.101'],
                                 'aaaarecord': [],
                             })

Succeeds, but trying to remove the IPv4 addresses again with dnsrecord_del:

api.Command["dnsrecord_del"](domain,
                             **{
                                 'idnsname': host_name,
                                 'arecord': ['192.168.100.100',
                                             '192.168.100.101'],
                                 'aaaarecord': [],
                             })

Fails with:

AttrValueNotFound("AAAA record does not contain 'None'",)

Steps to Reproduce

  1. Add host
  2. Add IPv4 addresses with dnsrecord_add using empty list aaaarecord for IPv6
  3. Try to delete IPv4 addresses with dnsrecord_del using empty list aaaarecord for IPv6

Actual behavior

Fails to remove the IPv4 addresses

Expected behavior

Removes IPv4 addresses

Version/Release/Distribution

Fails on RHEL-7:
ipa-server-4.6.4-10.el7.centos.3.x86_64
ipa-client-4.6.4-10.el7.centos.3.x86_64
389-ds-base-1.3.8.4-23.el7_6.x86_64
pki-ca-10.5.9-13.el7_6.noarch
krb5-server-1.15.1-37.el7_6.x86_64

Also on RHEL-8.1:
ipa-server-4.8.0-11.module+el8.1.0+4247+9f3fd721.x86_64
ipa-client-4.8.0-11.module+el8.1.0+4247+9f3fd721.x86_64
389-ds-base-1.4.1.3-7.module+el8.1.0+4150+5b8c2c1f.x86_64
pki-ca-10.7.3-1.module+el8.1.0+3964+500fc130.noarch
krb5-server-1.17-9.el8.x86_64


I looked into the issue. dnsrecord_del constructs an ipaldap.LDAPEntry object from the arguments:

LDAPEntry(ipapython.dn.DN('idnsname=test,idnsname=ipa.example.,cn=dns,dc=ipa,dc=example'), {'arecord': ['192.168.100.100', '192.168.100.101'], 'aaaarecord': []})

The dnsrecord_del.pre_callback method loops over the record types and eventually calls entry_attr['aaaarecord']. Internally the LDAPEntry class maps an entry with an empty list to None:

(Pdb) p entry_attrs['aaaarecord']
None

Since None is neither a tuple nor a list, the loop then creates a list [None].

master:

  • 856fdbc dnsrecord: Treat empty list arguments correctly

ipa-4-8:

  • 2ade60a dnsrecord: Treat empty list arguments correctly

Metadata Update from @abbra:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata