Univention Bugzilla – Bug 54669
KeyError: None on univention-app install
Last modified: 2022-06-13 15:10:02 CEST
univention-app install 4.4/prometheus=2.34.0 Traceback (most recent call last): File "/usr/bin/univention-app", line 97, in <module> main() File "/usr/bin/univention-app", line 84, in main ret = action(args) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/__init__.py", line 193, in call_with_namespace result = self.main(namespace) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/install.py", line 87, in main return self.do_it(args) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/install_base.py", line 169, in do_it success = self.do_it_once(app, args) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/install.py", line 203, in do_it_once return super(Install, self).do_it_once(app, args) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/install_base.py", line 214, in do_it_once self._do_it(app, args) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/docker_install.py", line 71, in _do_it ret = super(Install, self)._do_it(app, args) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/install.py", line 110, in _do_it self._register_app(app, args) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/register.py", line 435, in _register_app updates.update(self._register_docker_variables(app)) File "/usr/lib/python3/dist-packages/univention/appcenter/actions/register.py", line 489, in _register_docker_variables updates[app.ucr_image_key] = app.get_docker_image_name() File "/usr/lib/python3/dist-packages/univention/appcenter/app.py", line 1039, in get_docker_image_name image = content['services'][self.docker_main_service]['image'] File "/usr/lib/python3/dist-packages/ruamel/yaml/comments.py", line 702, in __getitem__ return ordereddict.__getitem__(self, key) KeyError: None (Pdb) content['services'] CommentedMap([('prometheus', CommentedMap([('image', 'prom/prometheus:v2.34.0'), ('restart', 'unless-stopped'), ('ports', ['9090:9090'])]))]) (Pdb) self.docker_main_service (Pdb) yml_file '/var/cache/univention-appcenter/appcenter-test.software-univention.de/4.4/prometheus_20220325213519.compose' (Pdb) self.uses_docker_compose() True → This is not a docker compose app - it was one. The check is wrong in: def uses_docker_compose(self): return os.path.exists(self.get_cache_file('compose')) It should evaluate the app.ini.
The problem appears to happen when one app that used to use docker compose stops using it in an update. It looks like all docker compose apps have `DockerMainService` defined in their `.ini` file so we could check for that instead (`grep -rli DockerMainService /var/cache/univention-appcenter/appcenter.software-univention.de/**/*.ini | sed 's/.ini$/.compose/' | xargs wc -l`).
MR merged, advisory updated (https://git.knut.univention.de/univention/ucs/-/commit/098b2bbe5a61007cd021bbdebaddecb5050026cd) and package built (`9.0.2-75A~5.0.0.202204221536`).
I see the problem. But this should be fixed in the App Provider Portal. I think this is clearly a misconfiguration of the ini file. Situation pre-patch: An App Provider may complain that they cannot change from docker-compose App to simple docker App. (Because the App still has a compose file) Situation post-patch: An App Provider may complain that they cannot change from simple docker App to docker-compose App. (Because the App still has a DockerImage defined)
What do you think Arvid? Should we close this issue?
Dirk instructed me to revert this change for now due to the time constraints for the UCS 5.0-2 release. I still think the changes are correct and we should do them. I tested the behavior in the App provider portal. Reverted in: univention-appcenter.yaml c0ab7668f761 | Revert "Bug #54669: use app configuration to determine if app uses compose" univention-appcenter (9.0.2-76) c0ab7668f761 | Revert "Bug #54669: use app configuration to determine if app uses compose" Successful build Package: univention-appcenter Version: 9.0.2-76A~5.0.0.202206081739 Branch: ucs_5.0-0 Scope: errata5.0-1