Univention Bugzilla – Bug 49423
reduce execution time of ou_create_post scripts
Last modified: 2019-05-08 22:26:31 CEST
Unify ou_create_post scripts, to reduce their execution time.
Six scripts have been joined into two, reducing execution time to 81%. Execution times are now logged. [4.4] 9a54da945 Bug #49423: unify ou_create_post scripts to reduce thier execution time [4.4] 559970d72 Bug #49423: log ou_create_post execution time [4.4] 0d925d401 Bug #49423: advisories ucs-school-import (17.0.6-12) ucs-school-umc-exam (9.0.0-8)
OK: code change OK: functional test OK: advisory
Something seems to be wrong with the 70http-api_school_create part. If a OU is created via project HTTP API, the OU is not known to the import HTTP API.
As the hooks run as children of a Django process, they inherit its environment variables. Django locates its central settings file by evaluating the Python class path in DJANGO_SETTINGS_MODULE. The default code for setting DJANGO_SETTINGS_MODULE is to run (in both manage.py and wsgi.py): ---- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ucsschool.http_api.app.settings") ---- This allows the caller to overwrite the project default from the command line (or application server). In our case it lead to both ou_create_post hooks (10update_schools and 53importgroup_import_api_school_update) to load the same Django project: the one in its parents environment variable. Thus 53importgroup_import_api_school_update (70http_api_school_create) didn't create the Django School objects in its database, but in the callers database. [4.4] 3c19d6fab Bug #49423: unset DJANGO_SETTINGS_MODULE env before importing Django [4.4] fae7d9416 Bug #49423: print API name [4.4] 89cabebe9 Bug #49423: quoting [4.4] 82c3d389a Bug #49423: execute each function in hooks [4.4] 46c14ab84 Bug #49423: changelog [4.4] 81f847389 Bug #49423: advisory update ucs-school-import (17.0.6-14)
OK: code change OK: manual test OK: advisory
UCS@school 4.4 v2 has been released. https://docs.software-univention.de/changelog-ucsschool-4.4v2-de.html If this error occurs again, please clone this bug.