Bug 52746 - KeyError: 'ucsschoolRole' in schoolrooms/computer
KeyError: 'ucsschoolRole' in schoolrooms/computer
Status: CLOSED WORKSFORME
Product: UCS@school
Classification: Unclassified
Component: UMC - Computer room administration
UCS@school 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS@school maintainers
:
: 51883 55500 (view as bug list)
Depends on: 49311
Blocks: 50349
  Show dependency treegraph
 
Reported: 2021-02-05 12:41 CET by Dirk Schnick
Modified: 2023-10-23 11:15 CEST (History)
15 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: 2021031521000165, 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
Comment 9 Maximilian Janßen univentionstaff 2021-11-26 14:15:11 CET
Version: 4.4-7 errata910 (Blumenthal) - UCS@school 4.4 v8

Error: 
Interner Server-Fehler in "schoolwizards/computers/query (schoolwizards/computers)".
Request: schoolwizards/computers/query (schoolwizards/computers)

Traceback (most recent call last):
  File "%PY2.7%/univention/management/console/base.py", line 359, in __error_handling
    six.reraise(etype, exc, etraceback)
  File "%PY2.7%/univention/management/console/base.py", line 262, in execute
    function.__func__(self, request, *args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "%PY2.7%/univention/management/console/modules/schoolwizards/__init__.py", line 246, in _decorated
    ret = func(self, request, *a, **kw)
  File "%PY2.7%/ucsschool/lib/school_umc_ldap_connection.py", line 146, in wrapper_func
    return func(*args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/schoolwizards/__init__.py", line 520, in get_computers
    return self._get_all(computer_class, school, request.options.get("filter"), ldap_user_read)
  File "%PY2.7%/univention/management/console/modules/schoolwizards/__init__.py", line 447, in _get_all
    objs.extend(klass.get_all(lo, school.name, filter_str=filter_str, easy_filter=True))
  File "%PY2.7%/ucsschool/lib/models/base.py", line 890, in get_all
    ret.append(cls.from_udm_obj(udm_obj, school, lo))
  File "%PY2.7%/ucsschool/lib/models/computer.py", line 380, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "%PY2.7%/ucsschool/lib/models/base.py", line 967, in from_udm_obj
    return klass.from_udm_obj(udm_obj, school, lo)
  File "%PY2.7%/ucsschool/lib/models/computer.py", line 380, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "%PY2.7%/ucsschool/lib/models/base.py", line 977, in from_udm_obj
    udm_value = udm_obj[attr.udm_name]
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 478, in __getitem__
    elif key not in self.__no_default and self.descriptions[key].editable:
KeyError: 'ucsschoolRole'

Role: domaincontroller_master
Comment 10 Carlos García-Mauriño univentionstaff 2022-05-18 16:38:45 CEST
We couldn't reproduce this bug. Also the latest traceback is from more than half a year ago.
Comment 11 Carlos García-Mauriño univentionstaff 2022-05-19 12:20:52 CEST
Please create (or clone) a new bug for UCS 5.0 if it happens again.
Comment 12 Carlos García-Mauriño univentionstaff 2023-03-10 14:52:52 CET
See https://forge.univention.org/bugzilla/show_bug.cgi?id=55500.
Comment 13 Jan-Luca Kiok univentionstaff 2023-10-23 11:15:21 CEST
*** Bug 55500 has been marked as a duplicate of this bug. ***
Comment 14 Jan-Luca Kiok univentionstaff 2023-10-23 11:15:26 CEST
*** Bug 51883 has been marked as a duplicate of this bug. ***