Bug 52214 - appcenter dependency on UCS errata version breaks installation from DVD during pre-join hook
appcenter dependency on UCS errata version breaks installation from DVD durin...
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: General
UCS@school 4.4
Other Linux
: P5 normal (vote)
: UCS@school 4.4 v7-errata
Assigned To: Daniel Tröder
Ole Schwiegert
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-10-13 16:59 CEST by Daniel Tröder
Modified: 2020-10-14 16:10 CEST (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 6: Setup Problem: Issue for the setup process
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 5: Blocking further progress on the daily work
User Pain: 0.171
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 Daniel Tröder univentionstaff 2020-10-13 16:59:32 CEST
The errata level on the UCS installation DVD (incl. for UCS 4.4-6) is below the one required by UCS@school 4.4 v7: "4.4-6 errata762".
The pre-join hook, retrieved from the DC master tries to install the same UCS@school version as is installed on the DC master. If that is "4.4 v7", then the installation will abort.

Modify the pre-join hook in a way that in case the required errata level is not met, a previous version (4.4 v6) of UCS@school is installed.
Comment 1 Daniel Tröder univentionstaff 2020-10-13 19:00:46 CEST
The pre-join hook now checks that if UCS@school 4.4 v7 is to be installed, that the errata level is at least "4.4.6-762". If that's not the case, then the version of UCS@school to install is changed to "4.4 v6".

Tested with two installations of school servers from DVD.

(On one server "update after installation" was enabled, on the other not. That doesn't make any difference, as updates are installed _after_ the join process, but I tested it anyway.)

----------------------------------------------------------------------------
univention-join-hooks: looking for hook type "join/pre-joinscripts" on m20.uni.dtr
Found hooks:
  cn=ucsschool-join-hook.py,cn=data,cn=univention,dc=uni,dc=dtr
Running: ucsschool-join-hook.py (cn=ucsschool-join-hook.py,cn=data,cn=univention,dc=uni,dc=dtr) in /tmp/tmpb3NX3i/tmpwfZDOh
2020-10-13 18:27:30,550 ucsschool-join-hook: [INFO] ucsschool-join-hook.py has been started
2020-10-13 18:27:30,553 ucsschool-join-hook: [INFO] Connecting to LDAP as 'uid=Administrator,cn=users,dc=uni,dc=dtr' ...
2020-10-13 18:27:30,596 ucsschool-join-hook: [INFO] Host is member of following groups: ['cn=DC Slave Hosts,cn=groups,dc=uni,dc=dtr', 'cn=DC-Edukativnetz,cn=ucsschool,cn=groups,dc=uni,dc=dtr', 'cn=OUgym21-DC-Edukativnetz,cn=ucsschool,cn=groups,dc=uni,dc=dtr']
2020-10-13 18:27:30,597 ucsschool-join-hook: [INFO] Determined role packages: ['ucs-school-slave']
2020-10-13 18:27:30,597 ucsschool-join-hook: [INFO] Calling ['univention-app', 'info', '--as-json'] ...
2020-10-13 18:27:31,055 ucsschool-join-hook: [INFO] Installed packages: []
2020-10-13 18:27:31,055 ucsschool-join-hook: [INFO] Is ucsschool already installed? False
2020-10-13 18:27:31,056 ucsschool-join-hook: [INFO] Calling ['univention-ssh', '/etc/machine.secret', 'edu21$@m20.uni.dtr', '/usr/sbin/ucr get version/version'] ...
2020-10-13 18:27:31,783 ucsschool-join-hook: [INFO] Calling ['ucr', 'get', 'version/version'] ...
2020-10-13 18:27:31,832 ucsschool-join-hook: [INFO] Master version: '4.4'
2020-10-13 18:27:31,832 ucsschool-join-hook: [INFO] Local version: '4.4'
2020-10-13 18:27:31,832 ucsschool-join-hook: [INFO] Calling ['univention-ssh', '/etc/machine.secret', 'edu21$@m20.uni.dtr', '/usr/bin/univention-app info --as-json'] ...
2020-10-13 18:27:34,215 ucsschool-join-hook: [INFO] Found UCS@school version u'4.4 v7' on DC master.
2020-10-13 18:27:34,216 ucsschool-join-hook: [WARNING] Current errata level to low ('4.4.4-652'), installing UCS@school version '4.4 v6' instead.
[..]
2020-10-13 18:28:17,706 ucsschool-join-hook: [INFO] Installing ucsschool=4.4 v6 ...
Going to install UCS@school (4.4 v6)
(must_have_valid_license) For the installation of this application, a UCS license key
                with a key identification (Key ID) is required
Creating data directories for ucsschool...
Registering UCR for ucsschool
Marking ucsschool=4.4 v6 as installed
----------------------------------------------------------------------------

[4.4] 2662d393c Bug #52214: improve type hints, logging.warn() deprected, don't execute code at import time
[4.4] 70ce880b7 Bug #52214: pre-join hook installs version 4.4 v6 of UCS@school if UCS packages are older than "4.4-6 errata762"
[4.4] ff5468918 Bug #52214: advisory update

ucs-school-metapackage (12.0.4-1)
Comment 2 Ole Schwiegert univentionstaff 2020-10-14 09:19:40 CEST
Tested by setting up UCS@school 4.4v7 Multiserver + new metapackage.
Installing UCS 4.4v5 without joining.

Join before updating -> 4.4v6 was installed
Join after updating -> 4.4v7 was installed

Code Review: OK with two additions

1) I would extract

```
            if LooseVersion(app_version) >= LooseVersion("4.4 v7"):
                # Bug #52214: The errata level on the UCS installation DVD (incl. for UCS 4.4-6) may be
                # below the one required by UCS@school 4.4 v7: "4.4-6 errata762". In such a case install
                # a UCS@school app version without that requirement (4.4 v6).
                errata_package = package_manager.get_package("univention-errata-level")
                if not LooseVersion(errata_package.installed.version) >= LooseVersion("4.4.6-762"):
                    app_version = "4.4 v6"
                    log.warning(
                        "Current errata level to low (%r), installing UCS@school version %r instead.",
                        errata_package.installed.version,
                        app_version,
                    )
```

into its own function, like `def determine_app_version(initial_app_version, package_manager)  #type: (str, PackageManager) -> str`

That would make it encapsulated from the rest of the logic and easily testable by unit tests. --> At this point I would add at least a simple set of unittests as well via univention-unittest since we did not want to add untested code anymore.

I would condense the two if statements into one AND if statement to avoid unnecessary indentation.

Otherwise it worked just fine.
Comment 3 Daniel Tröder univentionstaff 2020-10-14 13:24:14 CEST
The code was refactored and unit tests were added.

[4.4] 5b3f1a2de Bug #52214: refactor app version quirks into separate function
[4.4] 197a91d0f Bug #52214: add unit test
[4.4] 57bb28f40 Bug #52214: advisory update

ucs-school-metapackage (12.0.4-2)
Comment 4 Ole Schwiegert univentionstaff 2020-10-14 13:39:26 CEST
Package installs: OK
Changelog&Advisory: OK

I did a code review of the code itself and the unit tests, but did not repeat the manual test again. The function was just extracted and its return values are verified by the unit tests.
Comment 5 Daniel Tröder univentionstaff 2020-10-14 16:10:12 CEST
UCS@school 4.4 v7 (errata 2020-10-14) has been released.

https://docs.software-univention.de/changelog-ucsschool-4.4v7-de.html

If this error occurs again, please clone this bug.