Bug 44710 - KeyError: 'pTRRecord'
KeyError: 'pTRRecord'
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-5-errata
Assigned To: Florian Best
Dirk Wiesenthal
:
: 51736 51829 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-05-30 11:03 CEST by Florian Best
Modified: 2020-08-19 16:18 CEST (History)
7 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.091
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2018041121000711, 2017052921000751, 2020072421000302
Bug group (optional): External feedback
Max CVSS v3 score:


Attachments
patch (1.69 KB, patch)
2020-08-11 18:20 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2017-05-30 11:03:56 CEST
Version: 4.1-4 errata406 (Vahr)

Remark: Ich wollte die IP eines Hosts ändern

Die Ausführung des Kommandos udm/put computers/computer ist fehlgeschlagen:

Traceback (most recent call last):
  File "%PY2.7%/notifier/threads.py", line 82, in _run
    tmp = self._function()
  File "%PY2.7%/notifier/__init__.py", line 104, in __call__
    return self._function( *tmp, **self._kwargs )
  File "%PY2.7%/univention/management/console/modules/udm/__init__.py", line 405, in _thread
    module.modify(properties)
  File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 86, in _decorated
    return method(*args, **kwargs)
  File "%PY2.7%/univention/management/console/ldap.py", line 141, in _decorated
    result = func(*args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 445, in modify
    obj.modify()
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 317, in modify
    return self._modify(modify_childs, ignore_license=ignore_license)
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 815, in _modify
    self._ldap_post_modify()
  File "%PY2.7%/univention/admin/handlers/computers/ipmanagedclient.py", line 270, in _ldap_post_modify
    univention.admin.handlers.simpleComputer._ldap_post_modify(self)
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 2014, in _ldap_post_modify
    self.__remove_dns_reverse_object(self['name'], None, entry)
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 1568, in __remove_dns_reverse_object
    modify(rdn, zone)
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 1541, in modify
    if len(attributes['pTRRecord']) == 1:
KeyError: 'pTRRecord'
Comment 1 Johannes Keiser univentionstaff 2018-04-27 19:55:33 CEST
Reported again: Version: 4.2-3 errata312 (Lesum)

Remark: habe versucht, einem Host händisch eine neue IP-Adresse zu geben
Comment 2 Stefan Gohmann univentionstaff 2019-01-03 07:18:45 CET
This issue has been filled against UCS 4.1. The maintenance with bug and security fixes for UCS 4.1 has ended on 5st of April 2018.

Customers still on UCS 4.1 are encouraged to update to UCS 4.3. Please contact
your partner or Univention for any questions.

If this issue still occurs in newer UCS versions, please use "Clone this bug" or simply reopen the issue. In this case please provide detailed information on how this issue is affecting you.
Comment 3 Christina Scheinig univentionstaff 2020-07-24 09:53:44 CEST
Reported again from a customer with UCS Version: 4.4-4-652. It was updated from errata 528 -> 652 After that the error occurs.

Seems to be the same to me.

Interner Server-Fehler in "udm/put (computers/computer)".
Request: udm/put (computers/computer)

  File "/usr/lib/python2.7/dist-packages/notifier/threads.py", line 80,
in _run
    result = self._function()
  File "/usr/lib/python2.7/dist-packages/notifier/__init__.py", line
104, in __call__
    return self._function(*tmp, **self._kwargs)
  File
"/usr/lib/python2.7/dist-packages/univention/management/console/modules/udm/__init__.py",
line 440, in _thread
    module.modify(properties)
  File
"/usr/lib/python2.7/dist-packages/univention/management/console/modules/udm/udm_ldap.py",
line 645, in modify
    obj.modify()
  File
"/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py",
line 650, in modify
    dn = self._modify(modify_childs, ignore_license=ignore_license,
response=response)
  File
"/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py",
line 1331, in _modify
    self._ldap_post_modify()
  File
"/usr/lib/python2.7/dist-packages/univention/admin/handlers/computers/__base.py",
line 207, in _ldap_post_modify
    univention.admin.handlers.simpleComputer._ldap_post_modify(self)
  File
"/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py",
line 2722, in _ldap_post_modify
    self.__remove_dns_reverse_object(self['name'], None, entry)
  File
"/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py",
line 2275, in __remove_dns_reverse_object
    modify(rdn, zone)
  File
"/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py",
line 2248, in modify
    if len(attributes['pTRRecord']) == 1:
KeyError: 'pTRRecord'


Testcase:
Changing the IP of a device from 10.0.161.15 ->
10.0.161.150

-The Forward DNS entries are changed without errors
-For the Reverse DNS records there is no record for the .15 but for the .150 there are three records with all our DNS domains 

If we change the IP back (.150 -> .15)

-The Forward DNS entries are changed without errors
-The exception occurs
-The value is changed in the UI when I close the exception
-There are 3 new PTR records for the .15 with all our DNS domains
-The empty PTR record for the .150 remains

→ is this empty remaining record the cause why the exception occurs?
Comment 5 Florian Best univentionstaff 2020-07-27 15:16:04 CEST
*** Bug 51736 has been marked as a duplicate of this bug. ***
Comment 7 Florian Best univentionstaff 2020-08-11 18:20:03 CEST
Created attachment 10460 [details]
patch

In UDM we have required=True for the ptr_record property of dns/ptr_record. In LDAP the attribute is not required.
So we have a dns/ptr_record without ptr_record leading to this exception when trying to remove ptr record entries from it (e.g. when changing the computer's IP address).

So why do we have no ptr_record at the object?

management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py:
  2659 »   »   for entry in self.__changes['dnsEntryZoneReverse']['remove']:
  2667 »   »   »   »   self.__remove_dns_reverse_object(self['name'], dn, ip)
…
  2700 »   »   for entry in self.__changes['ip']['remove']:
  2722 »   »   »   self.__remove_dns_reverse_object(self['name'], None, entry)

→ because we are iterating over all DNS reverse pointers and remove them from the object. Without considering to remove the object if it has more than 1 ptr_records but we are removing both in the loop.
And then we are trying to remove all DNS reverse pointers for all the IP's we are removing from the object (which is the same IP as in the list of ptr_records before) which then causes the failure.

So we should fix both cases. No DNS ptr record exists (e.g. in already broken customer environments) and the broken removal when multiple pointer records exists.
See attached patch.
Comment 8 Florian Best univentionstaff 2020-08-11 18:54:18 CEST
Fixed in:

univention-directory-manager-modules (14.0.15-5)
a369142756c4 | Bug #44710: fix removal of dns/ptr_record when no ptr_record would be left over

ucs-test (9.0.4-41)
38037ab79edf | Bug #44710: add 66_udm-computers/58_removal_of_leftover_ptr_record_with_multiple_ip_addresses

univention-directory-manager-modules.yaml
f7ed4cf19632 | YAML Bug #44710
Comment 9 Florian Best univentionstaff 2020-08-11 18:57:44 CEST
(In reply to Christian Völker from Bug #51736 comment #1)
> Notes:
> Appears to be a regression as (according to customer) it flawlessly worked
> with UCS UCS 4.4-5 e528 but since the upgrade to 4.4-4 e652 the error
> appears.

This is not a regression. It's broken since ages, probably since UCS 3.
Comment 10 Dirk Wiesenthal univentionstaff 2020-08-17 22:06:26 CEST
Code: OK
Test: OK
YAML: OK
Comment 11 Florian Best univentionstaff 2020-08-18 09:16:58 CEST
*** Bug 51829 has been marked as a duplicate of this bug. ***