1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gitlab_ynh.git synced 2024-09-03 18:36:35 +02:00

fix check migration during upgrade

This commit is contained in:
Kayou 2024-07-02 11:37:59 +02:00 committed by GitHub
parent f7985f8e8f
commit 49566d96aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -178,27 +178,17 @@ then
# While the current version is not the last version, do an upgrade # While the current version is not the last version, do an upgrade
while [ "$last_version" != "$current_version" ] while [ "$last_version" != "$current_version" ]
do do
# https://docs.gitlab.com/ee/update/#checking-for-background-migrations-before-upgrading # https://docs.gitlab.com/ee/update/background_migrations.html
if dpkg --compare-versions "$current_version" "ge" "12.9"; then
checkBackgroundMigration=1
else
checkBackgroundMigration=0;
fi
if dpkg --compare-versions "$current_version" "ge" "15.1"; then if dpkg --compare-versions "$current_version" "ge" "15.1"; then
checkDBBackgroundMigration=2
elif dpkg --compare-versions "$current_version" "ge" "14.0"; then
checkDBBackgroundMigration=1
else
checkDBBackgroundMigration=0;
fi
if dpkg --compare-versions "$current_version" "ge" "14.7"; then
checkBatchedBackgroundMigration=1 checkBatchedBackgroundMigration=1
checkBackgroundMigration=0
else else
checkBatchedBackgroundMigration=0; checkBatchedBackgroundMigration=0
checkBackgroundMigration=1
fi fi
counter=0 counter=0
while [ $checkBackgroundMigration -eq 1 ] || [ $checkDBBackgroundMigration -ge 1 ] || [ $checkBatchedBackgroundMigration -eq 1 ] while [ $checkBackgroundMigration -eq 1 ] || [ $checkBatchedBackgroundMigration -eq 1 ]
do do
counter=$((counter + 1)) counter=$((counter + 1))
if [ $counter -gt 1200 ] if [ $counter -gt 1200 ]
@ -207,20 +197,12 @@ then
break break
fi fi
if [ $checkBackgroundMigration -eq 1 ] && gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining' | grep -q -w 0 if [ $checkBackgroundMigration -eq 1 ] && ((gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining' | grep -q -w 0) || (gitlab-rails runner -e production 'puts Gitlab::Database::BackgroundMigration::BatchedMigration.queued.count' | grep -q -w 0))
then then
checkBackgroundMigration=0 checkBackgroundMigration=0
fi fi
if [ $checkDBBackgroundMigration -eq 2 ] && gitlab-rails runner -e production 'puts Gitlab::Database::BackgroundMigration::BatchedMigration.queued.count' | grep -q -w 0 if [ $checkBatchedBackgroundMigration -eq 1 ] && gitlab-psql -c "SELECT job_class_name, table_name, column_name, job_arguments FROM batched_background_migrations WHERE status NOT IN(3, 6);" | grep -q -w 0
then
checkDBBackgroundMigration=0
elif [ $checkDBBackgroundMigration -eq 1 ] && gitlab-rails runner -e production 'puts Gitlab::Database::BackgroundMigrationJob.pending' | wc -l | grep -q -w 0
then
checkDBBackgroundMigration=0
fi
if [ $checkBatchedBackgroundMigration -eq 1 ] && echo "select COUNT(*) from batched_background_migrations where status <> 3;" | gitlab-psql -t -A | grep -q -w 0
then then
checkBatchedBackgroundMigration=0 checkBatchedBackgroundMigration=0
fi fi