Check for missing app code before upgrade#27047
Conversation
|
@VicDeo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @ringmaster and @PVince81 to be potential reviewers. |
11e0dfc to
4d96628
Compare
|
@PVince81 what do you think? |
Codecov Report
Continue to review full report at Codecov.
|
| $preUpdate = new \OC\Updater\PreUpdate(\OC::$server->getAppManager()); | ||
| $missingApps = $preUpdate->getMissingApps(); | ||
| if (count($missingApps) !== 0){ | ||
| $eventSource->send('notice', (string)$l->t('Code is missing for the following apps:')); |
There was a problem hiding this comment.
How does this look like in the web ui? Please add screenshot
There was a problem hiding this comment.
Any reason why this is being converted to a string? It should be returning a string already 😕
There was a problem hiding this comment.
@jvillafanez dunno, just like all the rest of $l->t() invocations in this file
| foreach ($missingApps as $appId){ | ||
| $eventSource->send('notice', $appId); | ||
| } | ||
| $eventSource->send('failure', (string)$l->t('Please use occ app:disable command if you don\'t need these apps or restore the code.')); |
There was a problem hiding this comment.
Kind of hard from the web ui ....
There was a problem hiding this comment.
my comment remains valid I guess .... what about auto-disabling them when accessing via web? or in a second request?
| /** | ||
| * @author Victor Dubiniuk <dubiniuk@owncloud.com> | ||
| * | ||
| * @copyright Copyright (c) 2017, ownCloud GmbH. |
| $this | ||
| ->setName('upgrade:checkapps') | ||
| ->setDescription('Check if there are enabled apps with missing code.') | ||
| ; |
There was a problem hiding this comment.
I'd move this up. It looks weird.
There was a problem hiding this comment.
@jvillafanez sorry, what's exactly wrong here?
There was a problem hiding this comment.
It's code style. Having a ; isolated there is weird.
There was a problem hiding this comment.
@jvillafanez thanks for clarification, updated.
| if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN){ | ||
| $output->writeln('Code is missing for the following apps:'); | ||
| $this->writeArrayInOutputFormat($input, $output, $missingApps); | ||
| $output->writeln('Please use occ app:disable command if you don\'t need these apps or restore the code.'); |
There was a problem hiding this comment.
I trust this works fine. I wouldn't like that the command the users is supposed to execute to fix the situation fails. Please confirm.
There was a problem hiding this comment.
deo@jah-mobile:~/public_html/oc-tmp> php occ app:list
Enabled:
- admin_audit: 0.7
- comments: 0.3.0
- dav: 0.2.8
- enterprise_key: true
- federatedfilesharing: 0.3.0
- federation: 0.1.0
- files: 1.5.1
- files_sharing: 0.10.0
- files_versions: 1.3.0
- gallery: 15.0.0
- provisioning_api: 0.5.0
- systemtags: 0.3.0
- updatenotification: 0.2.1
Disabled:
- activity
- encryption
- files_antivirus
- files_drop
- files_external
- files_texteditor
- files_trashbin
- files_videoviewer
- richdocuments
- templateeditor
- testing
deo@jah-mobile:~/public_html/oc-tmp> mv apps/admin_audit/ ../admin_audit
deo@jah-mobile:~/public_html/oc-tmp> php occ upgrade:checkapps
Code is missing for the following apps:
- admin_audit
Please use occ app:disable command if you don't need these apps or restore the code.
deo@jah-mobile:~/public_html/oc-tmp> php occ app:disable admin_audit
admin_audit disabled
deo@jah-mobile:~/public_html/oc-tmp> php occ upgrade:checkapps
deo@jah-mobile:~/public_html/oc-tmp>
| $this->writeArrayInOutputFormat($input, $output, [ 'missing' => $missingApps ]); | ||
| } | ||
|
|
||
|
|
| $preUpdate = new \OC\Updater\PreUpdate(\OC::$server->getAppManager()); | ||
| $missingApps = $preUpdate->getMissingApps(); | ||
| if (count($missingApps) !== 0){ | ||
| $eventSource->send('notice', (string)$l->t('Code is missing for the following apps:')); |
There was a problem hiding this comment.
Any reason why this is being converted to a string? It should be returning a string already 😕
| } | ||
|
|
||
| /** | ||
| * @return array |
There was a problem hiding this comment.
Taking into account this is a public method, the return value should be clearer. Is it returning a list of strings? a list of numbers? a list of app objects? an array with a specific format such as [<appid> => true]?
37921c6 to
b03332e
Compare
|
|
||
| use OCP\App\IAppManager; | ||
|
|
||
| class PreUpdate { |
There was a problem hiding this comment.
I don't have a clear idea what is the purpose of this class. Why is this class needed? Why we can't move the getMissingApps method inside the AppManager, or in any other class to manage apps?
There was a problem hiding this comment.
@jvillafanez This check is done before upgrade. And there will be more checks in future.
There was a problem hiding this comment.
Maybe an interface IPreUpgradeCheck with a doCheck method (not sure about what parameters should be included) might be a better choice.
For a specific check you can implement the interface and do whatever you want to do inside the doCheck method.
The only potential problem would be the implementation discovery. For now, core could create the implementations he's willing to go through during the upgrade process.
@DeepDiver1975 does it make sense?
There was a problem hiding this comment.
This check is done before upgrade. And there will be more checks in future.
please add this to the classÄ phpdoc
There was a problem hiding this comment.
Maybe an interface IPreUpgradeCheck with a doCheck method (not sure about what parameters should be included) might be a better choice.
since we do not expect any public api usage it is okay to it this way
| $missingApps = []; | ||
| foreach ($installedApps as $appId){ | ||
| $info = $this->appManager->getAppInfo($appId); | ||
| if (!isset($info['id'])){ |
There was a problem hiding this comment.
I guess you should better test for null
There was a problem hiding this comment.
@DeepDiver1975 May be both. What if there is no key id?
4144c2d to
5f985e1
Compare
|
@DeepDiver1975 updated, rebased, squashed. |
|
@DeepDiver1975 so, is it good enough now? |
|
Tested, works. However in the web UI I think the update should abort if apps have missing code. The reason is that if the app that is missing has some important routines like user backends, disabling that app is likely to break things because some migration code iterates over ALL users. But in the case of a missing user backend, some users would not be migrated at all. The CLI behavior is fine. |
|
and then comes the question: what about people who don't have CLI access, how would they disable these apps manually ? Hmmm... maybe the updater needs to show an error and then provide a button "click here to disble the apps" which reloads the page with an override URL parameter. thoughts ? |
|
@PVince81 as suggested by @DeepDiver1975 it is autodisabled in web UI. (See the last commit) |
|
The reason I asked for this feature was specifically to avoid migrations that forgot users due to disabled app. If we auto disable apps then we lose this and people will still result in broken envs. I could imagine this happening in case there are bugs in the "bundled app to market migration" code where for example user_ldap used to be on-disk (repo package) but now in the new version it's not there but must be downloaded from the market. But then if download failed and the upgrade continues (we likely don't want to continue here!), then user_ldap app is missing and the migration code of other apps that need all users will not find the LDAP users. |
|
of course user_ldap disallowes running web UI update, but some other user backends might |
|
This becomes even more important when unbundling apps to the marketplace. The risk of an app's code missing is much higher. |
1 similar comment
|
This becomes even more important when unbundling apps to the marketplace. The risk of an app's code missing is much higher. |
|
|
Obsoleted by #27711 |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |


Description
Related Issue
#26227
Motivation and Context
See issue
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: