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

Install / update with Nextcloud #929

Closed
mmallejac opened this issue Feb 8, 2023 · 23 comments
Closed

Install / update with Nextcloud #929

mmallejac opened this issue Feb 8, 2023 · 23 comments

Comments

@mmallejac
Copy link

Describe the bug
Issues with our update process for Snappy.

For all our ocker instances, we have a daily stop / start / update process that:

  • stop the instance with docker-compose stop
  • (do some update stuff)
  • start it again
  • then run a config script that do some stuff, including:
    docker exec --user www-data thisOne-nextcloud-1 php occ app:install snappymail (and all other apps that we use)
    docker exec --user www-data thisOne-nextcloud-1 php occ app:update snappymail (and all other apps that we use)
    docker exec --user www-data thisOne-nextcloud-1 php occ app:enable snappymail (and all other apps that we use)

This morning on some instances - not all ! - Nextcloud wasn't usable, GUI blocked on "need to process Snappy update", so I had to ... php occ upgrade for these instances, and then it was ok.

I can see in the config script log file that it went well until snappymail install command:

...
snappymail new version available: 2.25.4
snappymail updated
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
...

So it seems that Nextcloud put itself into maintenance mode just after installing / updating Snappymail.

You mentioned in #910 that SnappyMail can't be installed using cli yet but added this fix be0348b

Please complete the following information:

  • Browser: Firefox latest
  • IMAP daemon: [e.g. courier, dovecot]
  • PHP version: 8.1.14
  • SnappyMail Version: 2.25.4 on Nextcloud 25.0.3 dockerized

Also still not sure where the Snappymail app is supposed to be installed in: apps/ or custom_apps ?
On one instance this morning I had to move the snappymail folder from custom_apps to apps.
I've checked on all instances, and some have 2 install:

  • 2.25.2 under apps
  • 2.25.4 under custom_apps/
    Nextcloud is hopefully only aware of the new 2.25.4 and it is this one that is being run when starting it.
    It is probably due to some ugly fixing I had to do a few days ago when I was stuck during Error with 25.0.3 upgrade #910
    May I simply remove the old 2.25.2 under apps ?
@the-djmaze
Copy link
Owner

the-djmaze commented Feb 8, 2023

I know there are issues, but so far nobody found out why Nextcloud fails.
The issue is also mentioned in #904 but since you use CLI, i doubt the opcache is the issue.

Why Nextcloud moves SnappyMail around is very weird. You should think that Nextcloud always works the same.
Searching the web does reveal issues with custom_apps setups in Nextcloud config.php

@mmallejac
Copy link
Author

Ok I understand !

I'll try to reproduce the error and see if I can get some logs somewhere.

About the custom_apps vs apps, I am convinced that this is due to my ugly fixing last day. It doesn't seem to be a big issue, since it continues to work as expected. I'll do some cleanup to avoid having 2 snappymail apps present at the same time.

@mmallejac
Copy link
Author

Doing some testing, I've found this:

quicknotes 0.8.5 installed
quicknotes enabled
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
snappymail 2.25.5 installed
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
snappymail enabled

That happened while running my daily config script, at this line:
docker exec --user www-data test-nextcloud-1 php occ app:install snappymail

After that, I couldn't find anything within the nextcloud file space (docker volume) that did not belong to www-data (using find . ! -user www-data)

So something wrong happened, but without consequences here ?

On this test instance, no one has ever logged in since the instance creation.

@mmallejac
Copy link
Author

I've just done also another test, with a live instance that had 2.25.4, and the upgrade went fine: the whole ting has not been turned into maintenance mode.

Seen that on the console:

spreed already installed
tasks already installed
welcome already installed
snappymail new version available: 2.25.5
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
snappymail updated
calendar already enabled
collectives already enabled
contacts already enabled

So it is one of two things:

  • you've fixed something
  • the bug does not happen everytime

@HenkVirtual
Copy link

HenkVirtual commented Feb 9, 2023

Doing some testing, I've found this:

quicknotes 0.8.5 installed
quicknotes enabled
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
snappymail 2.25.5 installed
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
snappymail enabled

That happened while running my daily config script, at this line: docker exec --user www-data test-nextcloud-1 php occ app:install snappymail

After that, I couldn't find anything within the nextcloud file space (docker volume) that did not belong to www-data (using find . ! -user www-data)

So something wrong happened, but without consequences here ?

On this test instance, no one has ever logged in since the instance creation.

I have the same warning "PHP Warning: foreach() argument must be of type array|object, null given in /usr/share/nginx/html/nextcloud/apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239"
It looks like $items is not declared.

The system has the correct security settings. But the functionality of snappymail seems to be oke as far ik can see.

@the-djmaze
Copy link
Owner

I've also noticed the Undefined variable $items and should be fixed in next release.

It's good we are on to something why it fails.

@mmallejac
Copy link
Author

Hello !

So all my instances were in 2.25.4 yesterday, and I did some cleanup as well not to have 2 Snappymail installations present. So all instance had only one Snappymail install, whether it be under apps/ or custom_apps/.

This morning, my daily update process has tried to upgrade from 2.25.4 to 2.25.5, and:

Almost half were stuck in maintenance mode, and I had to run a php occ upgrade to finish the update job.
For each I had:

Updating <snappymail> ...
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  Undefined variable $items in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.25.5/app/libraries/snappymail/upgrade.php on line 239
Updated <snappymail> to 2.25.5

Then for another bunch (not exactly the same set), Snappymail was again duplicated: the old 2.25.4 under apps\ and the new 2.25.5 under custom_apps\, so I had to:

  • cat apps/snappymail/VERSION -> 2.25.4
  • cat custom_apps/snappymail/VERSION -> 2.25.5
  • rm -rf apps/snappymail/
  • mv custom_apps/snappymail/ apps/
  • for most of all Snappymail was then loading ok
  • for a few, I had to move it again from apps\ to custom_apps\ before it is loading fine

I hope that this will help to understand what's going on !

@the-djmaze
Copy link
Owner

@mmallejac
Copy link
Author

mmallejac commented Feb 10, 2023

Got it ! I wasn't aware that this happens also to other apps.

It shouldn't be too difficult to add some stuff into my update script to fix that, until Nextcloud fix that in their code.
I'll give some details here later.

EDIT: I've checked in details the three links, but IMHO none of the three links are similar to what we are facing here. They point to issues with having or not some parts of the Nextcloud install within a docker volume. I've also searched in the Nextcloud github issues and couldn't find something similar.

@the-djmaze
Copy link
Owner

First you need to figure out why it installs in apps or custom_apps as this is a Nextcloud thing.
When you are certain it installs always on the correct place, then why is Nextcloud in maintenance while upgrade succeeded?

If the cause is SnappyMail clearing the Opcache, then i won't remove the opcache trick because then a different issue pops up that is way more severe.
It's just a decision between two evils.

  1. SnappyMail crashes
  2. Nextcloud stuck in maintenance

In both cases people report issue but 1 needs restart of server and 2 needs to be fixed by Nextcloud.

As the opcache trick works for standalone upgrades.

@BiglifeMatt
Copy link

Just updated to 2.26.3 on my test server. It hung once again in maitanence mode but note this server is on Nextcloud version 25.0.3. I have been hesitant to update my production server but did it today. It is still on version 24.0.6. It actually never got stuck. So I don't know if the issue is something only with v.25. Can anyone verify this?

@HeyVern
Copy link

HeyVern commented Feb 24, 2023

image

Not sure. As I am getting the error above when trying to update now. Nextcloud Hub 3 (25.0.3)

@the-djmaze
Copy link
Owner

@HeyVern correct i fixed #991 and Nextcloud has serious issues regarding version numbers so it fails.
More important is that Nextcloud v25 really screwed up compared to v24.
And now that the European Privacy Board is starting a pilot with Nextcloud, it would be wise they fix v25 instead of placing everything on the v26 roadmap 😉

@HeyVern
Copy link

HeyVern commented Feb 25, 2023

@the-djmaze thanks! Good news, not only did it install now, but it also didn't trigger the maintenance mode issue I've been getting the last few update cycles. Well done!

@BiglifeMatt
Copy link

@the-djmaze I also just ran the 2.26.4 on my v.25 server and it didn't lock in maintenance mode this time either!

@the-djmaze
Copy link
Owner

the-djmaze commented Feb 25, 2023

Then i know what the bug in Nextcloud is.
At install it executes the app and the app had an exit i removed.

Now i wonder why Service::Handle() is executed at install/upgrade

@mmallejac
Copy link
Author

Hello !

This has just happened again, while upgrading the app from 2.28.0 to 2.28.1

  • NC put itself in maintenance mode
  • manually had to do an occ upgrade to get it back online

@the-djmaze
Copy link
Owner

I know this is annoying, but without error logs we have no clue why Nextcloud fails.

@BiglifeMatt
Copy link

BiglifeMatt commented Jun 8, 2023 via email

@HenkVirtual
Copy link

HenkVirtual commented Jun 8, 2023 via email

@mmallejac
Copy link
Author

mmallejac commented Jul 30, 2023

Hello !

I've done little progress here. I've written a few bash lines in order to fix the situation when things go wrong with Snappymail installation (when a version upgrade occurs).
Basically, it looks like this:

maintenanceMode=$($OCC status --output=json | jq ".maintenance")
[ "$maintenanceMode" = "true" ] && $OCC maintenance:mode --off 

needsDbUpgrade=$($OCC status --output=json | jq ".needsDbUpgrade")
[ "$needsDbUpgrade" = "true" ] && $OCC upgrade

snappyVersion=$($OCC app:list --output=json | jq ".enabled.snappymail" -r)
snappyPath=$($OCC app:getpath snappymail)

snappyIsInApps=$(grep -q $snappyVersion volumes/ncData/apps/snappymail/VERSION 2>/dev/null ; echo $?)
snappyIsInCustomApps=$(grep -q $snappyVersion volumes/ncData/custom_apps/snappymail/VERSION 2>/dev/null ; echo $?)

if [ "${snappyPath:14:11}" = "custom_apps" ] && [ $snappyIsInApps -eq 0 ]; then
                [ -d volumes/ncData/custom_apps/snappymail/ ] && rm -rf volumes/ncData/custom_apps/snappymail/
                mv volumes/ncData/apps/snappymail/ volumes/ncData/custom_apps/
                echo "!!! snappymail moved from apps to custom_apps !!!"
fi

if [ "${snappyPath:14:4}" = "apps" ] && [ $snappyIsInCustomApps -eq 0 ]; then
                [ -d volumes/ncData/apps/snappymail/ ] && rm -rf volumes/ncData/apps/snappymail/
                mv volumes/ncData/custom_apps/snappymail/ volumes/ncData/apps/
                echo "!!! snappymail moved from custom_apps to apps !!!"
fi

And tested that this morning but it does not work !
My script is based on the following assumption: a difference between $OCC app:getpath snappymail and the actual path where Snappymail is installed. This is wrong, because $OCC app:getpath snappymail always return the real path where Snappymail is installed, so it is possible this way to determine that the Snappymail installation should me moved from one place to another.

So now the question is: where inside Nextcloud is configured the path of Snappymail ? In other words where is it said whether Snappymail should be called in apps or in custom_app ? In Nextcloud, the link is always https://example.com/apps/snappymail/ whether it is set up in apps or in custom_app, so it must be somewhere else.
Maybe calculated on the fly ? If so, how ?

I've searched through the Nextcloud database but couldn't find the information.

@mmallejac
Copy link
Author

Silly question : since the issue is about Snappymail app location, how stupid whould it be to have a small line of script that would duplicate the current Snappymail into the other folder ? If inside apps then copy it into custom_apps and vice versa ?

the-djmaze pushed a commit to the-djmaze/nextcloud-server that referenced this issue Nov 20, 2023
the-djmaze pushed a commit that referenced this issue Nov 20, 2023
@the-djmaze
Copy link
Owner

the-djmaze commented Nov 20, 2023

I did some tests with my Nextlcoud 25.0.3 and can't reproduce the error.

[root@nextcloud]# sudo -u nextcloud php occ app:install snappymail
The current PHP memory limit is below the recommended value of 512MB.
snappymail 2.29.2 installed
snappymail enabled

[root@nextcloud]# sudo -u nextcloud php occ app:update snappymail
The current PHP memory limit is below the recommended value of 512MB.

[root@nextcloud]# sudo -u nextcloud php occ app:enable snappymail
The current PHP memory limit is below the recommended value of 512MB.
snappymail already enabled

What i did notice is that Nextcloud gives 0 to no feedback using app:update.
Did it finish? Did it crash? What?!?

So i modified Nextcloud code:
the-djmaze/nextcloud-server@0fb0c84
And now i get:

[root@nextcloud]# sudo -u nextcloud php occ app:update snappymail
The current PHP memory limit is below the recommended value of 512MB.
snappymail no new version available
Updates processed

I've also modified my install/upgrade/repair code to give more info
6552a93
This results in something like:

[root@nextcloud]# sudo -u nextcloud php occ maintenance:repair
The current PHP memory limit is below the recommended value of 512MB.
 - Repair MySQL collation
     - Not a mysql database -> nothing to do
 - ...
 - ...
 - ...
 - Setup SnappyMail
     - clearstatcache
     - opcache_reset
     - Load App
     - Fix permissions
     - Config not changed

Please use these changes to find your problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants