Bug 54669 - KeyError: None on univention-app install
KeyError: None on univention-app install
Status: REOPENED
Product: UCS
Classification: Unclassified
Component: App Center
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: Carlos García-Mauriño
Dirk Wiesenthal
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-04-13 19:30 CEST by Florian Best
Modified: 2022-06-13 15:10 CEST (History)
3 users (show)

See Also:
What kind of report is it?: Development Internal
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?:
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 Florian Best univentionstaff 2022-04-13 19:30:36 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.
Comment 1 Carlos García-Mauriño univentionstaff 2022-04-18 07:25:13 CEST
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`).
Comment 2 Carlos García-Mauriño univentionstaff 2022-04-22 15:58:36 CEST
MR merged, advisory updated (https://git.knut.univention.de/univention/ucs/-/commit/098b2bbe5a61007cd021bbdebaddecb5050026cd) and package built (`9.0.2-75A~5.0.0.202204221536`).
Comment 3 Dirk Wiesenthal univentionstaff 2022-04-25 09:38:57 CEST
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)
Comment 4 Carlos García-Mauriño univentionstaff 2022-05-18 11:24:24 CEST
What do you think Arvid? Should we close this issue?
Comment 5 Florian Best univentionstaff 2022-06-08 17:42:46 CEST
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