Bug 54064 - UDM REST API does not handle nagios/service objects - HTTP 500 - RuntimeError: Object was not opened
UDM REST API does not handle nagios/service objects - HTTP 500 - RuntimeError...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-2-errata
Assigned To: Florian Best
Iván.Delgado
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-11-15 16:05 CET by Daniel Tröder
Modified: 2022-11-16 18:03 CET (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2021-11-15 16:05:31 CET
When opening a nagios/service object in the UDM REST API a HTTP 500 is returned. The traceback in the response and log file is:

15.11.21 16:04:06       ERROR      (     1681) : Uncaught exception GET /udm/nagios/service/cn=UNIVENTION_DISK_ROOT,cn=nagios,dc=uni,dc=dtr (0.0.0.0)
    HTTPServerRequest(protocol='http', host='10.200.3.31', method='GET', uri='/udm/nagios/service/cn=UNIVENTION_DISK_ROOT,cn=nagios,dc=uni,dc=dtr', version='HTTP/1.1', remote_ip='0.0.0.0')
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/tornado/web.py", line 1592, in _execute
        result = yield result
      File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1133, in run
        value = future.result()
      File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1147, in run
        yielded = self.gen.send(value)
      File "/usr/lib/python3/dist-packages/univention/admin/rest/module.py", line 2622, in get
        self.set_entity_tags(obj)
      File "/usr/lib/python3/dist-packages/univention/admin/rest/module.py", line 2688, in set_entity_tags
        self.set_header('Etag', self.get_etag(obj))
      File "/usr/lib/python3/dist-packages/univention/admin/rest/module.py", line 2697, in get_etag
        raise RuntimeError('Object was not opened!')
    RuntimeError: Object was not opened!
15.11.21 16:04:06       ERROR      (     1681) : 500 GET /udm/nagios/service/cn=UNIVENTION_DISK_ROOT,cn=nagios,dc=uni,dc=dtr (0.0.0.0) 14.06ms
ERROR:tornado.access:500 GET /udm/nagios/service/cn=UNIVENTION_DISK_ROOT,cn=nagios,dc=uni,dc=dtr (127.0.0.1) 22.69ms
Comment 1 Daniel Tröder univentionstaff 2021-11-15 16:07:41 CET
Problem does not exist in 4.4.
Comment 2 Florian Best univentionstaff 2021-11-15 16:24:30 CET
It looks like a UDM error.
This patch should fix it?!:

diff --git management/univention-directory-manager-modules/modules/univention/admin/handlers/nagios/service.py management/univention-directory-manager-modules/modules/univention/admin/handlers/nagios/service.py
index 537c87498a..c55c48c42b 100644
--- management/univention-directory-manager-modules/modules/univention/admin/handlers/nagios/service.py
+++ management/univention-directory-manager-modules/modules/univention/admin/handlers/nagios/service.py
@@ -247,6 +247,7 @@ class object(univention.admin.handlers.simpleLdap):
                return info
 
        def open(self):
+               super(object, self).open()
                _re = re.compile(r'^([^.]+)\.(.+?)$')
                # convert host FQDN to host DN
                hostlist = []
Comment 3 Daniel Tröder univentionstaff 2021-11-17 16:38:38 CET
Above patch make nagios/service work. I navigated through the web interface there and retrived the list of all nagios/service objects without an error:

17.11.21 16:37:29        INFO      (    32092) : 200 GET /udm/ (0.0.0.0) 556.00ms
17.11.21 16:37:31        INFO      (    32092) : 200 GET /udm/navigation/ (0.0.0.0) 85.48ms
17.11.21 16:37:39        INFO      (    32092) : 200 GET /udm/nagios/service/ (0.0.0.0) 19.73ms
17.11.21 16:37:41        INFO      (    32092) : 200 GET /udm/nagios/service/?position=&hidden=1&property=&query%5B%5D=*&page=1&limit=0&by=&dir=ASC (0.0.0.0) 126.24ms
Comment 4 Florian Best univentionstaff 2022-11-10 09:38:26 CET
Reproducer:
curl -H 'Accept: application/json' http://Administrator:univention@localhost/univention/udm/nagios/service/cn%3DUNIVENTION_RAID%2Ccn%3Dnagios%2C"$(ucr get ldap/base)"
Comment 5 Florian Best univentionstaff 2022-11-10 11:38:51 CET
The missing open() super call has been added.

univention-directory-manager-modules.yaml
854c4daca2db | fix(udm nagios/service): fix missing call to super `open()` in `nagios/service`

univention-directory-manager-modules (15.0.13-15)
854c4daca2db | fix(udm nagios/service): fix missing call to super `open()` in `nagios/service`
Comment 6 Iván.Delgado univentionstaff 2022-11-11 13:24:59 CET
Verified:
 * Comment 4
 * Advisory
 * ucs-test-udm-rest