Bug 55245 - Reduce number of validation messages during user creation
Reduce number of validation messages during user creation
Status: NEW
Product: UCS@school
Classification: Unclassified
Component: HTTP-API (Kelvin)
UCS@school 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS@school maintainers
:
Depends on:
Blocks: 55246
  Show dependency treegraph
 
Reported: 2022-10-06 12:38 CEST by Tobias Wenzel
Modified: 2023-06-12 16:12 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 1: Cosmetic issue or missing function but workaround exists
Who will be affected by this bug?: 4: Will affect most installed domains
How will those affected feel about the bug?: 1: Nuisance – not a big deal but noticeable
User Pain: 0.023
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:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Wenzel univentionstaff 2022-10-06 12:38:02 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.
Comment 1 Tobias Wenzel univentionstaff 2022-10-06 12:40:27 CEST
bug for 5.0 https://forge.univention.org/bugzilla/show_bug.cgi?id=55246