Bug 43816 - App Setting: Implement setting for an App
App Setting: Implement setting for an App
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: App Center
UCS 4.1
Other All
: P5 normal (vote)
: UCS 4.1-4-errata
Assigned To: Dirk Wiesenthal
Eduard Mai
:
: 29649 42455 (view as bug list)
Depends on: 43825
Blocks: 42455 43402 43817 43838 44750 44755
  Show dependency treegraph
 
Reported: 2017-03-13 09:22 CET by Dirk Wiesenthal
Modified: 2023-03-25 06:39 CET (History)
8 users (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?: Yes
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2017050321000343
Bug group (optional):
Max CVSS v3 score:


Attachments
A list of all settings currently supported (26.23 KB, image/png)
2017-06-14 10:09 CEST, Dirk Wiesenthal
Details
.settings (917 bytes, text/plain)
2017-06-14 10:10 CEST, Dirk Wiesenthal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Wiesenthal univentionstaff 2017-03-13 09:22:18 CET
Goal is to allow Apps to specify custom setting that are then applied inside the container / on the host.

Specification is done via a new file: myapp.settings with is dritten in ini format:

[my/setting]
...
[my/second/setting]
...
Comment 1 Dirk Wiesenthal univentionstaff 2017-04-07 10:13:01 CEST
*** Bug 29649 has been marked as a duplicate of this bug. ***
Comment 2 Erik Damrose univentionstaff 2017-05-03 14:13:12 CEST
An ISV asked for this feature: Two Variables should be configured for an app, which should trigger a ucr set for two respective UCRVs. Their scenario: Configure repository credentials
Comment 3 Dirk Wiesenthal univentionstaff 2017-06-07 13:53:14 CEST
Done. Please note that a configure script is a Docker script, so it does not work for Non-Docker that easily.

But: UCR variables work. One could register a UCR script.
Comment 4 Dirk Wiesenthal univentionstaff 2017-06-07 13:56:40 CEST
*** Bug 42455 has been marked as a duplicate of this bug. ***
Comment 5 Dirk Wiesenthal univentionstaff 2017-06-14 10:09:23 CEST
Created attachment 8921 [details]
A list of all settings currently supported
Comment 6 Dirk Wiesenthal univentionstaff 2017-06-14 10:10:31 CEST
Created attachment 8922 [details]
.settings
Comment 7 Felix Botner univentionstaff 2017-06-15 17:05:59 CEST
@eduard, kannst du bitte parallel QA machen
Comment 8 Eduard Mai univentionstaff 2017-06-16 17:48:58 CEST
During app installation, when a file widget with 'Write = Install' was added but no file is uploaded and the user proceeds to install: 

Die Ausführung des Kommandos appcenter/docker/progress ist fehlgeschlagen:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/base.py", line 281, in execute
    function(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 318, in _response
    result = _multi_response(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 462, in _response
    return list(function(self, iterator, *nones))
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 284, in _fake_func
    yield function(self, *args)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/mixins.py", line 149, in progress
    ret = progress_obj.poll()
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 309, in _thread
    result = _multi_response(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 462, in _response
    return list(function(self, iterator, *nones))
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 284, in _fake_func
    yield function(self, *args)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/appcenter/__init__.py", line 391, in invoke_docker
    result['success'] = action.call(app=app, username=self.username, password=self.password, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/__init__.py", line 196, in call
    return obj.call_with_namespace(namespace)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/__init__.py", line 202, in call_with_namespace
    result = self.main(namespace)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/install.py", line 67, in main
    return self.do_it(args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/install_base.py", line 123, in do_it
    self._do_it(app, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/docker_install.py", line 63, in _do_it
    ret = super(Install, self)._do_it(app, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/install.py", line 85, in _do_it
    self._configure(app, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/install_base.py", line 306, in _configure
    configure.call(app=app, set_vars=args.set_vars)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/__init__.py", line 196, in call
    return obj.call_with_namespace(namespace)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/__init__.py", line 202, in call_with_namespace
    result = self.main(namespace)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/configure.py", line 65, in main
    self._set_config(args.app, set_vars, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/docker_configure.py", line 58, in _set_config
    super(Configure, self)._set_config(app, set_vars, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/configure.py", line 85, in _set_config
    setting.set_value(app, value)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/settings.py", line 199, in set_value
    return self._write_file_content(docker.path(self.filename), value)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/settings.py", line 177, in _write_file_content
    self.warn('Could not set content: %s' % exc)
AttributeError: 'FileSetting' object has no attribute 'warn'
Comment 9 Eduard Mai univentionstaff 2017-06-19 16:58:11 CEST
Die Ausführung des Kommandos appcenter/docker/progress ist fehlgeschlagen:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/base.py", line 281, in execute
    function(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 318, in _response
    result = _multi_response(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 462, in _response
    return list(function(self, iterator, *nones))
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 284, in _fake_func
    yield function(self, *args)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/mixins.py", line 149, in progress
    ret = progress_obj.poll()
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 309, in _thread
    result = _multi_response(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 462, in _response
    return list(function(self, iterator, *nones))
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 284, in _fake_func
    yield function(self, *args)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/appcenter/__init__.py", line 391, in invoke_docker
    result['success'] = action.call(app=app, username=self.username, password=self.password, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/__init__.py", line 196, in call
    return obj.call_with_namespace(namespace)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/__init__.py", line 202, in call_with_namespace
    result = self.main(namespace)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/install.py", line 67, in main
    return self.do_it(args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/install_base.py", line 123, in do_it
    self._do_it(app, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/docker_install.py", line 63, in _do_it
    ret = super(Install, self)._do_it(app, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/install.py", line 84, in _do_it
    if self._install_app(app, args):
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/docker_install.py", line 57, in _install_app
    self._start_docker_image(app, hostdn, password, args)
  File "/usr/lib/pymodules/python2.7/univention/appcenter/actions/docker_base.py", line 161, in _start_docker_image
    if 'Install' in setting.write or 'Upgrade' in setting.write:
AttributeError: 'StringSetting' object has no attribute 'write
Comment 10 Dirk Wiesenthal univentionstaff 2017-06-20 10:42:18 CEST
Fixed those tracebacks.

FYI: After discussion, we changed
Write = 
to
Show = 

and 
Read = 
to
ShowReadOnly =
Comment 11 Felix Botner univentionstaff 2017-06-20 16:28:07 CEST
* Default values are not applied for installation,
  but later (if the setting is empty)
  maybe we should respect defaults only for the installation?

minor:

 * Installation log error for every setting
   [   ERROR]: Cannot read nc/string while nextcloud=11.0.3-0 is not running
   => this is not an error
   
 * if i set a attribute to ''
    [    INFO]: Setting nc/string to None
   => better Unsetting nc/string ...
Comment 12 Felix Botner univentionstaff 2017-06-20 17:05:57 CEST
container upgrade resets settings


Going to install Nextcloud (11.0.2-0)
...
Calling configure
Setting nc/noinstall to 'my aa'
Setting nc/string to 'my default'
...
Going to upgrade Nextcloud (11.0.3-0)
Setting nc/noinstall to 'aa'
Setting nc/string to 'default'

-> univention-app shell nextcloud cat /etc/univention/base.conf| grep nc
nc/bool: true
nc/noinstall: aa
nc/string: default
Comment 13 Dirk Wiesenthal univentionstaff 2017-06-21 01:35:37 CEST
Should be fixed in
  univention-appcenter 5.0.23-86.320.201706210133

There is still a configure step during image upgrade (like Nextcloud) because of the way an image upgrade is performed.

But as no script is executed there (only variables are set) and the variables are overwritten in the next step, this seems fine.
Comment 14 Felix Botner univentionstaff 2017-06-21 13:33:28 CEST
(In reply to Dirk Wiesenthal from comment #13)
> Should be fixed in
>   univention-appcenter 5.0.23-86.320.201706210133
> 
> There is still a configure step during image upgrade (like Nextcloud)
> because of the way an image upgrade is performed.
> 
> But as no script is executed there (only variables are set) and the
> variables are overwritten in the next step, this seems fine.

OK, works

* app settings are removed when uninstalling the app
  -> this is OK, but could we backup the settings before removing the app?
     (maybe to /var/lib/univention-appcenter/apps/$APP/settings)
  -> maybe also a hint in the remove dialog that all the app settings 
     are removed?

* default value should only apply for the installation
Comment 15 Felix Botner univentionstaff 2017-06-21 13:42:11 CEST
Required = True does not seem to have an effect?
Comment 16 Felix Botner univentionstaff 2017-06-21 13:46:47 CEST
Type = File

shows the content of the File in UMC, univention-app configure  --list and in /var/log/univention/appcenter.log.

I uploaded a binary file and messed up my terminal, better not display the content (just the filename?)
Comment 17 Felix Botner univentionstaff 2017-06-21 13:49:27 CEST
A Type = File can't be deleted, ist this OK?

For Type = Password(File) only one password input field is generate, so no protection against typo's?
Comment 18 Felix Botner univentionstaff 2017-06-21 16:55:42 CEST
as discussed, 
 * merge to 4.2
 * revert in 4.1
 * Milestone errata4.2-1
Comment 19 Johannes Keiser univentionstaff 2017-06-26 14:11:30 CEST
It's now impossible to build univention-system-setup:

run-parts: tests/test_setup_script_profile exited with return code 1
Traceback (most recent call last):
  File "tests/test_setup_script_ucr", line 10, in <module>
    from setup_script import TransactionalUcr
  File "tests/../umc/python/setup/setup_script.py", line 39, in <module>
    from util import PATH_SETUP_SCRIPTS, PATH_PROFILE
  File "tests/../umc/python/setup/util.py", line 68, in <module>
    from univention.appcenter.actions import get_action
  File "/usr/lib/pymodules/python2.7/univention/appcenter/__init__.py", line 34, in <module>
    from univention.appcenter.app import App, AppManager
  File "/usr/lib/pymodules/python2.7/univention/appcenter/app.py", line 54, in <module>
    from univention.appcenter.settings import Setting
  File "/usr/lib/pymodules/python2.7/univention/appcenter/settings.py", line 50, in <module>
    class Setting(TypedIniSectionObject):
  File "/usr/lib/pymodules/python2.7/univention/appcenter/settings.py", line 54, in Setting
    type = IniSectionAttribute(default='String', choices=['String', 'Int', 'Bool', 'List', 'Password', 'File', 'PasswordFile', 'Status'])
TypeError: __init__() got an unexpected keyword argument 'choices'
Comment 20 Dirk Wiesenthal univentionstaff 2017-06-27 13:56:03 CEST
Reverted for 4.1-4. Please verify the revert as it was a lot.
Comment 21 Eduard Mai univentionstaff 2017-06-27 19:38:22 CEST
It seems to me, that the revert also removes parts of r80236. Have a look at management/univention-appcenter/python/appcenter/actions/remove.py

Otherwise it looks clean.
Comment 22 Eduard Mai univentionstaff 2017-06-28 11:14:37 CEST
(In reply to Eduard Mai from comment #21)
> It seems to me, that the revert also removes parts of r80236. Have a look at
> management/univention-appcenter/python/appcenter/actions/remove.py
> 
> Otherwise it looks clean.

This is wrong, the missing line is in docker_upgrade.py.
Comment 24 Dirk Wiesenthal univentionstaff 2017-06-28 12:55:22 CEST
As discussed, I think the revert is okay. I have deleted two empty files and adjusted the YAML
  univention-appcenter 5.0.23-88.321.201706281252
Comment 25 Eduard Mai univentionstaff 2017-06-28 13:03:09 CEST
yaml: OK

Package: univention-appcenter
Version: 5.0.23-88.321.201706281252
Branch: ucs_4.1-0
Scope: errata4.1-4

OK - app settings behave as before the revert

VERIFIED