Univention Bugzilla – Bug 55245
Reduce number of validation messages during user creation
Last modified: 2023-06-12 16:12:24 CEST
In https://forge.univention.org/bugzilla/show_bug.cgi?id=55233 we reduced the log level, number of log entries and printed everything in one line. This is a follow up bug/issue to reduce the log calls: When creating a user like curl -X 'POST' \ 'http://10.200.68.5/ucsschool/kelvin/v1/users/' \ -H 'accept: application/json' \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "ucsschool_roles": [ "student:school:DEMOSCHOOL" ], "name": "test", "school": "https://10.200.68.5/ucsschool/kelvin/v1/schools/DEMOSCHOOL", "firstname": "test", "lastname": "test", "record_uid": "test", "roles": [ "https://10.200.68.5/ucsschool/kelvin/v1/roles/student" ], "schools": [ "https://10.200.68.5/ucsschool/kelvin/v1/schools/DEMOSCHOOL" ], "school_classes": {}, "workgroups": {}, "source_uid": "DEMOID" }' The following log messages are are emitted: ... 2022-10-05 15:27:26 INFO [1940][7810e767fe] ImportStudent(name='test', school='DEMOSCHOOL', dn='uid=test,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet') successfully created 2022-10-05 15:27:26 WARNING [1940][7810e767fe] 346bb9ed-8b32-4eb5-aa85-32e2754231ce UCS@school Object uid=test,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet with options {'pki': False, 'ucsschoolStudent': True, 'ucsschoolTeacher': False, 'ucsschoolStaff': False, 'ucsschoolAdministrator': False, 'ucsschoolExam': False} has validation errors: is missing groups at positions ['cn=klassen,cn=schueler,cn=groups,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet'] 2022-10-05 15:27:26 WARNING [1940][7810e767fe] 367b714f-10c6-42ae-ac11-0c4e4e3db977 UCS@school Object uid=test,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet with options {'pki': False, 'ucsschoolStudent': True, 'ucsschoolTeacher': False, 'ucsschoolStaff': False, 'ucsschoolAdministrator': False, 'ucsschoolExam': False} has validation errors: is missing groups at positions ['cn=klassen,cn=schueler,cn=groups,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet'] 2022-10-05 15:27:26 INFO [1940][7810e767fe] Success creating ImportStudent(name='test', school='DEMOSCHOOL', dn='uid=test,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet'). 2022-10-05 15:27:26 WARNING [1940][7810e767fe] 6eea7732-d7cb-4dd3-bf31-eee214115162 UCS@school Object uid=test,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet with options {'pki': False, 'ucsschoolStudent': True, 'ucsschoolTeacher': False, 'ucsschoolStaff': False, 'ucsschoolAdministrator': False, 'ucsschoolExam': False} has validation errors: is missing groups at positions ['cn=klassen,cn=schueler,cn=groups,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet'] 2022-10-05 15:27:26 WARNING [1940][7810e767fe] 9b519fd0-9d0a-4b72-92bd-2012876470ff UCS@school Object uid=test,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet with options {'pki': False, 'ucsschoolStudent': True, 'ucsschoolTeacher': False, 'ucsschoolStaff': False, 'ucsschoolAdministrator': False, 'ucsschoolExam': False} has validation errors: is missing groups at positions ['cn=klassen,cn=schueler,cn=groups,ou=DEMOSCHOOL,dc=skurup-68-5,dc=intranet'] 2022-10-05 15:27:26 INFO [1940][7810e767fe] 172.17.42.1:55766 - "POST /ucsschool/kelvin/v1/users/ HTTP/1.1" 201 -> 4x for the same object. I had a short look into the calls which are made during the creation. post: get_import_user -> get_udm_object UserCreateModel -> _as_lib_model_kwargs UserModel -> _from_lib_model_kwargs -> 2 x get_udm_object (in UserModel + LibModelHelperMixin) I also found this potential candidate: import_user.py:: call_hooks -> get_by_import_id -> get_only_udm_obj + from_udm_obj There might be more. Daniel's suggestion: > Maybe we could store somewhere in the stack that we created a warning with certain arguments and then when we want to emit the next warning, and there is already a warning in the stack and it has the same arguments, we don't emit it... interesting problem... This should be implemented for ucsschool 5.0 as well.
bug for 5.0 https://forge.univention.org/bugzilla/show_bug.cgi?id=55246