mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
nextcloud: During upgrade wait properly for upgrade to complete
- Before rerunning setup operations. Tests: - Install version 28-fpm (one version older than the current stable). Then change it stable-fpm and increment the nextcloud app version at the same time. Start the service. Notice that nextcloud app setup is rerun, container will be updated by podman to newer version. Setup completes successfully with the patch but fails arbitrarily otherwise as the setup process does not wait for the upgrade to complete and tries to prematurely re-run setup operations. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
2a30d64f08
commit
a7911469ee
@ -201,12 +201,33 @@ def _set_database_privileges(db_password: str):
|
||||
|
||||
def _nextcloud_wait_until_ready():
|
||||
"""Wait for Nextcloud container to get ready."""
|
||||
|
||||
def _versions_match():
|
||||
"""Return if versions in shipped and runtime directories match.
|
||||
|
||||
Nextcloud container ships with source in /usr/source/nextcloud. This is
|
||||
copied to /var/www/html/ when there is a mismatch between their
|
||||
version.php. The last step in the coping process is the copy of
|
||||
version.php file itself.
|
||||
"""
|
||||
try:
|
||||
source_version = '/usr/src/nextcloud/version.php'
|
||||
runtime_version = '/var/www/html/version.php'
|
||||
_run_in_container('diff', source_version, runtime_version)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
# Nextcloud copies sources from /usr/src/nextcloud to /var/www/html inside
|
||||
# the container. Nextcloud is served from the latter location. This happens
|
||||
# on first run of the container and when upgrade happen.
|
||||
# on first run of the container and when upgrade happen. Checking for
|
||||
# existence of version.php is easy and works for first install. For
|
||||
# upgrades, we must wait until source is copied to the runtime directory.
|
||||
# The last file to be copied the version.php. Only after this is checking
|
||||
# for the lock file below meaningful.
|
||||
start_time = time.time()
|
||||
while time.time() < start_time + 300:
|
||||
if (_data_path / 'version.php').exists():
|
||||
if (_data_path / 'version.php').exists() and _versions_match():
|
||||
break
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user