Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't do app upgrades in the background #9866

Merged
merged 10 commits into from
Aug 19, 2014
Merged

Don't do app upgrades in the background #9866

merged 10 commits into from
Aug 19, 2014

Conversation

icewind1991
Copy link
Contributor

This removes the logic for transparently upgrading apps and moves it to the same system we use for core upgrades.
Transparent app upgrades can leave the instance in a broken state when requests are being processed in parallel.

Only doing the upgrades in the foreground prevents this and provide a way for users to know when an upgrade failed.

cc @DeepDiver1975 @PVince81

*/
public static function loadApp($app) {
public static function loadApp($app, $checkUpgrade = true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we default this to false instead or do you think there's a risk to break other things ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo defaulting to false provides a bigger risk (an accidental app being loaded without properly being upgraded)

@PVince81
Copy link
Contributor

To test:

Main update

Single app update

  • Single app update: blocks all connections until accessed through web UI
  • Single broken app update: blocks connections, stays blocked after upgrade

@PVince81
Copy link
Contributor

Ok from what I see, whenever an app needs upgrade, the "Upgrade to OC 8" page appears again.
We might want to change the text later to make sure people know it's just about updating apps.
CC @owncloud/designers

@PVince81
Copy link
Contributor

Bonus point for the fact that you're now showing what app is being updated 😄

@PVince81
Copy link
Contributor

  • test with third party apps that need update
  • test what happens when updating app from app store

@PVince81
Copy link
Contributor

@georgehrke do you see any conflict with this and the app store approach of updating ?
Short version: this PR will display the update page as soon as there is at least one app that need updating (when code_version > db_version)

@PVince81
Copy link
Contributor

  • TODO: move the core version setting to the end

@PVince81
Copy link
Contributor

Just tested the following:

  1. Install mozilla_sync (with the code checker off...)
  2. Set version to 1.3 in appinfo/version
  3. Set version to 1.3 in the database.
  4. Update mozilla_sync from the apps page
  5. Refresh the page

At step 4) it looks like only the code is updated, but the actual DB upgrade occurs after a page refresh, where the "upgrade to OC8" page appears.
This also means that as soon as an app is updated, no further ajax calls will be allowed.
So either the app store update should be changed automatically refresh the page.

We need to make sure that this worklow is acceptable, or tweak it.

@PVince81
Copy link
Contributor

  • properly integrate with app store: maybe make app store refresh the page, but not sure about the UX, needs to be discussed

Also I'm not sure about the impact of this.
Would be definitely nice to sort out in OC 8 but not sure about 7.0.1.

@PVince81
Copy link
Contributor

Apart from the the code looks good 😄
Thanks @icewind1991

@jancborchardt
Copy link
Member

Hm, does that mean that whenever an app needs a upgrade, the blocking page will be shown? Should only be invokable by admins, no?

@georgehrke
Copy link
Contributor

code looks good, don't see any direct conflicts with app updates for shipped apps, didn't test though. Will try to find time for testing this tomorrow

@PVince81
Copy link
Contributor

@jancborchardt, yes only admins. Other users would get "Service not available" or something until the admin runs the upgrade procedure.
I like that approach for the core update but think it's a bit cumbersome for individual apps.

@jancborchardt
Copy link
Member

@PVince81 wait – but that »Service not available« page in the first place only appears once the admin dedicatedly pushes the »update app« switch, right? Otherwise it sounds like app updates will halt the installation until an admin is there.

@MorrisJobke
Copy link
Contributor

@jancborchardt App updates are invoked by admins ;) There is no auto-updater

@schiessle
Copy link
Contributor

I'm not sure if I like the idea of the update screen for every app update. This can be quite irritating especially
if a different user visits the side exactly at this moment. What happens if multiple apps needs to be updated, will I get a separate update screen for each app?

Why not just activate the maintenance mode before we call the update script? This way we make sure that the script gets triggered only once and we can still perform the updates in the background on-demand.

@icewind1991
Copy link
Contributor Author

There are 2 cases for upgrading apps

  • an app is updated from the web ui, in that case we could enable maintance mode in ajax and perform the upgrade transparently
  • an app is updated by the admin replacing the code, that case is when we need to show to upgrade page

I'll look into "fixing" updating apps from the app store

@schiessle
Copy link
Contributor

  • an app is updated by the admin replacing the code, that case is
    when we need to show to upgrade page

can you elaborate on it? I don't know the code, so maybe I miss
something obvious, but why can't we just switch to maintenance mode if
we detect a version change right before calling the update.php?

@icewind1991
Copy link
Contributor Author

The app store now properly set the app version in the database after updating, when updating an app trough the app store you no longer need to go trough the upgrade page

@icewind1991
Copy link
Contributor Author

can you elaborate on it? I don't know the code, so maybe I miss
something obvious, but why can't we just switch to maintenance mode if
we detect a version change right before calling the update.php?

The problem is that the upgrade would be triggered by whatever request happens to be next, neither we nor the admin updating the app has any control when the upgrade would be triggered. By going trough the update page we not only ensure parallel requests dont try to both update the app but also ensure there is someone to respond to any error that might happen

@ghost
Copy link

ghost commented Jul 25, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/6406/

@schiessle
Copy link
Contributor

What's the status? Isn't it something we would like to have for OC7.0.1?

@icewind1991
Copy link
Contributor Author

Rebased, I think all raised issues are taken care of now

@ghost
Copy link

ghost commented Aug 4, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/6526/

foreach ($apps as $appId) {
if (\OC_App::shouldUpgrade($appId)) {
\OC_App::updateApp($appId);
$this->emit('\OC\Updater', 'appUpgrade', array($appId, $version));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undefined variable $version

@PVince81
Copy link
Contributor

I retested with the steps from #9866 (comment) and everything works fine now.

Upgrading a single third party app by clicking on "Update now" simply sets the maintenance mode during upgrade, which provides a better UX than before.

However there is one last small issue:

  • BUG: app version does not appear in upgrade status message due to "Undefined variable $version" (see inline comment)

@icewind1991 please fix that then this is good to go.

@PVince81
Copy link
Contributor

Fixes #9856
Fixes #9817

@PVince81
Copy link
Contributor

@karlitschek @craigpg I have the feeling this would be useful to have in 7.0.2.
People have been reporting concurrency issues in 7.0.1 even with the patches that fixed them.

@schiesbn please also help reviewing

@PVince81
Copy link
Contributor

@icewind1991 any update ?

@icewind1991
Copy link
Contributor Author

Fixed the undefined variable

@scrutinizer-notifier
Copy link

A new inspection was created.

@PVince81
Copy link
Contributor

Works 👍

@PVince81
Copy link
Contributor

This needs another reviewer @schiesbn @DeepDiver1975 @th3fallen

@ghost
Copy link

ghost commented Aug 18, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/6768/

@th3fallen
Copy link
Contributor

Works for me as well 👍 some unit tests wouldn't hurt though....

@PVince81
Copy link
Contributor

@icewind1991 add unit tests separately ? From what I remember it's quite difficult with the current structure and might require some refactoring...

@icewind1991
Copy link
Contributor Author

@icewind1991 add unit tests separately ? From what I remember it's quite difficult with the current structure and might require some refactoring...

Yes, I'm not sure how to add unit tests atm

icewind1991 added a commit that referenced this pull request Aug 19, 2014
Don't do app upgrades in the background
@icewind1991 icewind1991 merged commit fdfc5c6 into master Aug 19, 2014
@icewind1991 icewind1991 deleted the app-upgrade branch August 19, 2014 11:33
@MorrisJobke
Copy link
Contributor

@icewind1991 @karlitschek Backport needed and possible?

@karlitschek
Copy link
Contributor

please backport

@icewind1991
Copy link
Contributor Author

Backport would be useful to increase upgrade stability

@icewind1991
Copy link
Contributor Author

Stable7: c69215c...7842014

@lock lock bot locked as resolved and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants