Skip to content

Commit

Permalink
Test upgrade of 2023.06
Browse files Browse the repository at this point in the history
LAVA from 2023.01 to 2023.05 miss a migration script which is generated by
lava-docker but with a "automatic" name.
LAVA 2023.06 has the correct migration script but you cannot have both
at the same time.
Add a detection of this situation to rollback automatic migration.

In the same time replace all migration action via the postinst.py which
do the correct action.

Signed-off-by: Corentin LABBE <[email protected]>
  • Loading branch information
montjoie committed Sep 12, 2023
1 parent aeca7df commit 6ccad32
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,21 @@ jobs:
run: cd output/local && docker-compose up -d
- name: Wait for LAVA to be started
run: sh .github/workflows/wait-for-docker.sh

- name: Run backup of 2023.01
run: ./backup.sh
- name: stop docker
run: cd output/local && docker-compose down

- name: Clean old install
run: rm -r output
- name: Copy backup
run: cp -v backup-latest/* lava-master/backup/
- name: Run lavalab-gen
run: ./lavalab-gen.py boards-ci-2023.06.yaml
- name: Build lava-docker 2023.06
run: cd output/local && docker-compose build
- name: Launch lava-docker 2023.06
run: cd output/local && docker-compose up -d
- name: Wait for LAVA 2023.06 to be started
run: sh .github/workflows/wait-for-docker.sh
12 changes: 11 additions & 1 deletion .github/workflows/wait-for-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ do
fi
fi
fi
docker-compose logs --tail=50
docker-compose logs --tail=60
docker ps > /tmp/alldocker
grep -q master /tmp/alldocker
if [ $? -ne 0 ];then
echo "=========================================="
echo "=========================================="
echo "=========================================="
echo "ERROR: master died"
docker-compose logs
exit 1
fi
sleep 10
TIMEOUT=$((TIMEOUT+10))
done
Expand Down
29 changes: 29 additions & 0 deletions boards-ci-2023.06.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
masters:
- name: masterci1
version: "2023.06"
host: local
healthcheck_url: http://healthcheck
users:
- name: admin
token: tokenforci
password: passwordforci
superuser: true
staff: true
tokens:
- username: admin
token: dfjdfkfkdjfkdsjfslforci
description: no description
slaves:
- name: lab-ci-0
version: "2023.06"
host: local
remote_master: masterci1
remote_user: admin
use_overlay_server: false
use_tftp: false
host_healthcheck: true

boards:
- name: qemu-01
type: qemu
58 changes: 54 additions & 4 deletions lava-master/entrypoint.d/01_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
fi

cd /root/
lava-server manage makemigrations || exit $?
#lava-server manage makemigrations || exit $?

# verify that the backup was not already applied in case of persistent_db
if [ ! -e "/var/lib/postgresql/lava-docker.backup_done" ];then
Expand All @@ -28,7 +28,7 @@ if [ ! -e "/var/lib/postgresql/lava-docker.backup_done" ];then
if [ -e /root/backup/db_lavaserver ];then
echo "Restore database from backup"
sudo -u postgres psql < /root/backup/db_lavaserver || exit $?
yes yes | lava-server manage migrate || exit $?
#yes yes | lava-server manage migrate || exit $?
echo "Restore jobs output from backup"
rm -r /var/lib/lava-server/default/media/job-output/*

Expand All @@ -51,8 +51,58 @@ else
echo "DEBUG: backup already applied"
fi

lava-server manage makemigrations
yes yes | lava-server manage migrate || exit $?
# check current LAVA version
# not very good way, but no real choice
echo "DEBUG: check LAVA version from DB"
su - postgres -c 'psql --tuples-only lavaserver -c "SELECT DISTINCT version from lava_scheduler_app_worker" | sort -V' > /tmp/workerversions
sed -i 's,^[[:space:]]*,,' /tmp/workerversions
echo "======"
cat /tmp/workerversions
echo "======"

echo "DEBUG: check LAVA version from file"
cat /usr/lib/python3/dist-packages/lava_common/VERSION
# hack
grep -q '2023.01' /usr/lib/python3/dist-packages/lava_common/VERSION
if [ $? -eq 0 ];then
echo "DEBUG: 2023.01 need to do an old migration"
lava-server manage makemigrations
yes yes | lava-server manage migrate || exit $?
fi
# if we came from 2023.01 to 2023.05, we need to handle the migration bug
grep -q '2023.0[1-5]' /tmp/workerversions
if [ $? -eq 0 ];then
grep -q 2023.06 /usr/lib/python3/dist-packages/lava_common/VERSION
if [ $? -eq 0 ];then
echo "============================="
echo "DEBUG: handle DB migration BUG"
sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_scheduler_app';"
echo "============================="
sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_results_app';"
echo "============================="
lava-server manage migrate --fake lava_results_app 0019_update_query_contenttype || exit $?
echo "============================="
lava-server manage migrate --fake lava_scheduler_app 0057_dt_permissions_worker_master_version || exit $?
echo "============================="
lava-server manage migrate lava_results_app 0018_drop_buglink || exit $?
echo "============================="
lava-server manage migrate lava_scheduler_app 0056_testjob_queue_timeout || exit $?
echo "============================="
sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_scheduler_app';"
echo "============================="
sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_results_app';"
echo "============================="
else
echo "DEBUG: no spetial handling for DB"
fi
else
echo "DEBUG: no spetial handling for DB"
fi

echo "DEBUG: call postinst for managing migrations"
/usr/share/lava-server/postinst.py || exit $?
#lava-server manage makemigrations
#yes yes | lava-server manage migrate || exit $?

# default site is set as example.com
if [ -e /root/lava_http_fqdn ];then
Expand Down

0 comments on commit 6ccad32

Please sign in to comment.