Bug 52746 - KeyError: 'ucsschoolRole' in schoolrooms/computer
KeyError: 'ucsschoolRole' in schoolrooms/computer
Status: NEW
Product: UCS@school
Classification: Unclassified
Component: UMC - Computer room administration
UCS@school 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS@school maintainers
:
Depends on: 49311
Blocks: 50349
  Show dependency treegraph
 
Reported: 2021-02-05 12:41 CET by Dirk Schnick
Modified: 2021-09-01 12:28 CEST (History)
12 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?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.206
Enterprise Customer affected?: Yes
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2020070121000122, 2021011207000031, 2021061021000267
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Schnick univentionstaff 2021-02-05 12:41:17 CET
Problem occurs again in customer environment. Customer has IP Devices, MAC and windows computer. Some of them, however created maybe very old objects, don't have a ucsschoolRole. The searchfilter of the module should be rugged enough to handle such computer objects.


Interner Server-Fehler in "schoolrooms/computers".
Request: schoolrooms/computers

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 359, in __error_handling
    six.reraise(etype, exc, etraceback)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 262, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/school_umc_ldap_connection.py", line 140, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolrooms/__init__.py", line 67, in computers
    } for x in SchoolComputer.get_all(ldap_user_read, request.options['school'], pattern)]
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 869, in get_all
    ret.append(cls.from_udm_obj(udm_obj, school, lo))
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 375, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 945, in from_udm_obj
    return klass.from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 375, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 954, in from_udm_obj
    udm_value = udm_obj[attr.udm_name]
  File "/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py", line 478, in __getitem__
    elif key not in self.__no_default and self.descriptions[key].editable:
KeyError: 'ucsschoolRole'


###################################################################################################


+++ This bug was initially created as a clone of Bug #49311 +++

The schoolroom UMC doesn't initialize all UDM objects causing the following traceback when opening the UMC module:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/base.py", line 253, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 192, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 145, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolrooms/__init__.py", line 61, in computers
    } for x in SchoolComputer.get_all(ldap_user_read, request.options['school'], pattern)]
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 808, in get_all
    ret.append(cls.from_udm_obj(udm_obj, school, lo))
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 293, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 859, in from_udm_obj
    return klass.from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 293, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 866, in from_udm_obj
    udm_value = udm_obj[attr.udm_name]
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 466, in __getitem__
    elif key not in self.__no_default and self.descriptions[key].editable:
KeyError: 'ucsschoolRole'

Probably the bug is in the UCS@school models lib:

get_class_for_udm() doesn't handle DC Slaves.
IMO it should return ShoolDCSlave.
This would probably™ cause that the correct UDM initialization is done?!
Comment 1 Erik Damrose univentionstaff 2021-02-05 12:51:47 CET
At previous bugs Bug 49311 and Bug 50349 a script was developed to fix these issues - does this help?

/usr/share/ucs-school-import/scripts/fix_ucsschool_roles --dry-run

Please also provide the ldapsearch output of an affected computerobject
Comment 2 Dirk Schnick univentionstaff 2021-02-05 13:43:16 CET
The script throws a traceback.

You can find requested detailed information in the ticket: 
https://otrs.knut.univention.de/otrs/index.pl?Action=AgentTicketZoom;TicketID=1061646;ArticleID=2264828#
Comment 3 Daniel Tröder univentionstaff 2021-02-08 09:26:17 CET
There are errors in the LDAP data of computer objects.
But there is also an error in the fix_ucsschool_roles script.
I have requested further LDAP dumps to both a) reproduce the problem in fix_ucsschool_roles and b) check for more inconsistent LDAP objects.
Comment 4 Dirk Schnick univentionstaff 2021-02-11 10:12:35 CET
How do we go on in this case. The object was deleted; correct. But Daniel wrote there is a error in the script fix_ucsschool_roles. Do you need further information to solve this?
Comment 7 Christian Castens univentionstaff 2021-06-21 14:06:43 CEST
reported again: 
Ticket: 2021061021000267
Version: 4.4-8 errata992 (Blumenthal) - UCS@school 4.4 v9