Bug 42690

Summary: App Center does not make sure the database exists when reinstalling an app
Product: UCS Reporter: Jürn Brodersen <brodersen>
Component: App CenterAssignee: Jens Pelzetter <pelzetter>
Status: CLOSED FIXED QA Contact: Dirk Wiesenthal <wiesenthal>
Severity: normal    
Priority: P5 CC: damrose, gulden, heidelberger, wiesenthal
Version: UCS 4.3   
Target Milestone: UCS 4.3-2-errata   
Hardware: Other   
OS: Linux   
What kind of report is it?: Bug Report What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 3: Will affect average number of installed domains How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.257 Enterprise Customer affected?: Yes
School Customer affected?: ISV affected?: Yes
Waiting Support: Flags outvoted (downgraded) after PO Review:
Ticket number: Bug group (optional):
Max CVSS v3 score:

Description Jürn Brodersen univentionstaff 2016-10-17 10:40:55 CEST
When installing an app that has a database in its ini file, the appcenter only checks if the database user is already created. It would be nice to check for the table as well.

While this should only affect developers, I think it would help ISV to debug their app.
Comment 2 Erik Damrose univentionstaff 2018-06-07 15:44:42 CEST
For the App Center the create_database() call succeeds if a password and a DB user for the app exist. That is not enough. If we allow ISVs to add arbitrary scripts which can backup and delete the DB, we have to ensure everything is working when an app is installed.

The App Center does not check
* if the correct database exists (would get bonus points for checking GRANTS to db user)
* if the db user can login with the password from the secrets file

Workaround for ISV: when dropping the DB, also delete $appid.secret
Comment 3 Dirk Wiesenthal univentionstaff 2018-06-07 16:07:01 CEST
Yes, we do give App Providers the ability to delete the DB in a script. But they have to do this explicitly. We do not support deleting the DB for them.

Therefore, I would not call this a workaround, but the way to go. (Granted, this is tedious work for App Providers)

Currently, the checks are limited for performance reasons. The database is part of the registration and therefore executed quite often. Maybe we could remove the database integration from the registration and then do more expensive checks.

(Even the db_user_exists() check would be skipped if there would not exist some corner cases where this is actually a problem during installation - no custom scripts involved)
Comment 4 Valentin Heidelberger univentionstaff 2018-11-20 13:43:12 CET
After a failed upgrade of the owncloud app it turned out to be a missing database (or rather an empty one) to be the cause for failing re-installation of the app. We had to install the app with --do-not-revert and afterwards use docker inspect to find the cause in error messages from owncloud.
Comment 5 Jens Pelzetter univentionstaff 2018-11-29 08:52:57 CET
The checks for the existence now check
if the database exists by querying the internal tables of the database and if the database user exists.
Comment 6 Dirk Wiesenthal univentionstaff 2018-11-30 14:00:23 CET
OK, works
Comment 7 Arvid Requate univentionstaff 2018-12-05 14:39:05 CET
<http://errata.software-univention.de/ucs/4.3/345.html>