Bug 52506 - App Settings in outside scope should be applied before containers are created and started
App Settings in outside scope should be applied before containers are created...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: App Center
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-0-errata
Assigned To: Dirk Wiesenthal
Erik Damrose
:
Depends on:
Blocks: 53609 53630
  Show dependency treegraph
 
Reported: 2020-12-16 12:19 CET by Nico Gulden
Modified: 2021-08-04 13:21 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 1: Nuisance – not a big deal but noticeable
User Pain: 0.034
Enterprise Customer affected?:
School Customer affected?:
ISV affected?: Yes
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Workaround is available
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Gulden univentionstaff 2020-12-16 12:19:07 CET
The apps Jitsi and Bitwarden use App Settings with the outside scope and store the values in UCR variables. Furthermore, both apps use an environment file which is a UCR template referring to UCR variables that are created by the app settings.

The problem is that app settings are evaluated after the Docker containers are created and started. The environment file is not yet updated and therefore the containers are initialized with the wrong values.

The workaround for the problem is to add the following if block to the `configure_host` lifecycle script in the app:

if [ "$1" = "install" ]; then
    univention-app reinitialize $appid
fi

This causes the the re-evaluation of the app settings and the UCR templates like compose and environment file for the app during the installation process. The containers are thrown away and recreated with the correct settings. The UCR variables are still configured from the initial installation run. Afterwards, the join script is run.

The order of certain tasks during the installation process needs to be reviewed. As administrator and app provider I expect that app settings made before installation are correctly applied to the Docker containers regardless of the App Settings' scope. UCR template files like the app's Docker compose and the environment file also need to be taken into account.
Comment 2 Felix Botner univentionstaff 2021-03-17 12:40:19 CET
Should also work for package based apps

Setting:
...
Show = Install, Settings
Scope = outside
Required = yes

Start App Install, apply settings in App Settings Form, install the app

currently this fails with:

12997 actions.configure                21-03-16 16:19:51 [    INFO]: Configuring app=1.0 
112997 actions.configure                21-03-16 16:19:51 [CRITICAL]: Failed to configure: app: mysetting is required
Comment 3 Felix Botner univentionstaff 2021-07-23 14:33:10 CEST
* we only set settings, if they are given as set_vars (which is done for default values in UMC automatically)
* set variables before preinst (so that one can check the settings in the preinst)
* only set "outside" scope settings
Comment 4 Felix Botner univentionstaff 2021-07-23 15:36:43 CEST
7a3b13f4ad6be948b9626102e30db7488496e793 - univention-appcenter
 * added _set_outside_settings_in_ucr before _call_prescript during installation

489bbe0cae41713f00eda66f5f2dff9d8d1282aa - ucs-test
 * added 100_settings.py::test_outside_settings_in_preinst

28ecd067ba72c0d60578e5e87d43d27964289a62 - yaml


The idea is that one ca use the preinst to test the settings and to abort the installation:

preinst:

eval "$(univention-config-registry shell)"

for i in "$@"; do
    case "$i" in
        --binddn)
            shift 2
        ;;
        --locale)
            shift 2
        ;;
        --old-version)
            old_version="$2"
            shift 2
        ;;
        --error-file)
            error_file="$2"
            shift 2
        ;;
        --version)
            version="$2"
            shift 2
        ;;
    --bindpwdfile)
            shift 2
        ;;
        *)
        ;;
    esac
done

if [ "$myapp_mysetting1" != "setting ]; then
    echo "myapp/mystetting1 must be 'setting'" > $error_file
    exit 1
fi

exit 0
Comment 5 Dirk Wiesenthal univentionstaff 2021-07-27 01:04:43 CEST
Done as advised in Bug #53609 Comment 2.

Reverted 7a3b13f4ad6be948b9626102e30db7488496e793

Instead, we fixed _configure and use it in

41023bd1

The tests still work. We do not yet test InitialValue and Upgrade/Remove yet. It should work, though.

I also added a sentence to the documentation.
Comment 6 Erik Damrose univentionstaff 2021-07-28 17:31:34 CEST
OK: univention-appcenter 9.0.2-57A~5.0.0.202107270016
OK: Fix _configure call
OK~ Testcases in 20_appcenter/100_settings.py
I added an 'apt-get update' call to the testcases, as the test failed on several roles, as the dummy package libcurl4-doc was not installable
OK: yaml

Verified
Comment 7 Erik Damrose univentionstaff 2021-07-28 19:10:11 CEST
<https://errata.software-univention.de/#/?erratum=5.0x57>