Skip to content

Updating

A.s. edited this page Nov 30, 2026 · 99 revisions

Steps Overview (TOC)

Note

This is the default, stop-everything flow. Hosts that have run make bg-init deploy instead with near-zero downtime: see Blue/Green deployment. make prod refuses to run on those hosts (it would delete the database volume).

  1. Preparation
  2. Backup
  3. New Deployment

Preparation

As early as possible

Preferably, this should be done on the previous day(s). Tasks marked with a tick may be skipped safely.

  • If there were changes to models. On parkour-dev, make update-fixtures. Then, stage and commit anything needed.
    • Formatting will be done by pre-commit hook. (Differences like the JSON values that are lists spanning multiple lines can be staged to commit.)

Note

We have two VMs. First, production (hostname: parkour), and secondly, a staging environment (hostname: parkour-dev). In both cases, the directory that holds the repo is ~/parkour2 .

Server git note: The git on the VMs is too old for git -C. Use git --git-dir=... --work-tree=... or cd first.

Rollback images: docker compose build re-tags :latest, leaving the currently running image untagged. A later docker system prune -a -f would delete it, breaking a quick rollback. If you need a rollback path, tag the old image before pruning: docker tag parkour2-parkour2-django:latest parkour2-parkour2-django:prev-26.10.05 (and similarly for vite). The guide below runs docker system prune -a -f at the very end; skip it if you want to keep the old images.

Backup

In order to minimize downtime, we can build the new images while going through the backup process. So, ssh into production VM and run:

# build the new images
mkdir -p ~/upgrade
cd ~/upgrade                                                                                            
git clone --depth=1 --branch 26.11.26 https://github.com/maxplanck-ie/parkour2
cd parkour2

# OPTIONAL: check free disk space before build (the build added ~22G in 2026-11-26)
df -h / | tail -1

# Tag current :latest for rollback (do this BEFORE docker compose build)
docker tag parkour2-parkour2-django:latest parkour2-parkour2-django:prev-$(git --git-dir="$HOME/parkour2/.git" --work-tree="$HOME/parkour2" describe --tags --abbrev=0)
# repeat for other services if needed: parkour2-parkour2-vite, parkour2-parkour2-nginx, etc.

docker compose build

Note

Pin the clone to the release tag (--branch 26.11.26), not the develop branch head. The tag is pushed in Preparation step 7.

Leave that running. On another shell, ssh into production again, and then:

make --directory ~/parkour2 sweep

# The following two commands are idempotent: if ~/pk2_old was already removed, they safely no-op.
# `ls -ld` returns "No such file or directory" (exit 2) instead of showing a real directory.
# `rm -rf` on a non-existent path succeeds.
ls -ld ~/pk2_old/media 2>/dev/null || true   # MUST start with "l" (symlink to /root/pk2media). If "d": STOP, see warning below.
rm -rf ~/pk2_old

date >> ~/last.txt
docker ps >> ~/last.txt
git --git-dir="$HOME/parkour2/.git" --work-tree="$HOME/parkour2" log | head -1 >> ~/last.txt

Warning

Media must never live inside a release folder. Uploads live in /root/pk2media; every release folder only holds a media symlink to it. rm -rf ~/pk2_old removes a symlink without following it, so the uploads survive. But if ~/pk2_old/media is a real directory (ls -ld shows d), that rm -rf destroys every upload in it. That happens when the ln -s /root/pk2media ~/parkour2/media step of New Deployment is skipped: make prod only prints a warning and creates an empty local ./media, and the app then silently stores uploads in the release folder. Never put a trailing slash on it (~/pk2_old/media/), and never rm -rf anything under /root/pk2media.

Meanwhile, go into your development/ staging VM (e.g. parkour-dev) and start the app that's a mirror (code and data) of production:

ssh root@parkour-dev
cd parkour2
make down
git pull --ff-only   # fast-forward only; if it refuses, STOP and investigate
# Pick the PREVIOUS release tag (lexical sort + version sort, not `tail -2 | head -1`):
PREV_TAG=$(git tag | sort -V | tail -2 | head -1)
echo "Checking out previous release: $PREV_TAG"
git checkout "$PREV_TAG"   # e.g. 26.10.05
make import-pgdb dev db-migras
docker exec parkour2-django python manage.py check

Note

git tag | tail -2 | head -1 sorts lexically and breaks once the new tag (e.g. 26.11.26) is fetched. Use git tag | sort -V | tail -2 | head -1 instead.

import-pgdb runs make save-postgres on production as a side effect (it SSHes to parkour and creates a fresh dump there, repointing latest.sqldump). This is expected and authorized; it only adds a file and the app keeps running.

Open this app in a browser tab, navigate submodules (Library Preparation, Index Generator, Pooling, Load Flowcells, etc.); and confirm that all numbers look the same as production. We'll come back to this mirror to check everything is good, once we finish the whole process...

Important

Give a heads-up to both Bioinformatics and Sequencing Facility now β€” you're about to stop production. Only send this notice at this point (not during the build), because docker compose build takes a long time and there's no need to warn users until you're actually pulling the plug.

docker exec parkour2-rsnapshot rsnapshot halfy
make --directory ~/parkour2 save-postgres tar-old-migras
cd ~/parkour2; docker compose -f docker-compose.yml -f misc/nginx.yml -f misc/rsnapshot.yml stop; cd -
make --directory ~/parkour2 clean
mv ~/parkour2 ~/pk2_old

Important

tar-old-migras must run here, while the old release is still the one checked out: it packs the migrations that match the schema of the .sqldump written just before. The tarball and the dump are a matched pair; never re-run it later against a different checkout. The final block of New Deployment re-saves both together for the new release.

The ~/pk2_old folder is for quick and easy restoration: you will simply need to come back to this folder, rename it, and run the corresponding make commands to re-deploy the service with the proper backup data that's in place.

Note

If the production server carries a hotfix that was never committed to GitHub (e.g. the checked-out commit 5abec95 differs from the tag 26.10.05 at 073d4b6), document the hotfix in the changelog or in a separate HOTFIXES.md file so it isn't lost on the next upgrade.

New Deployment

Warning

Only move to this section after the docker compose build has finished. Ideally, this was run in previous days and a new recent re-build would only take 2-3 minutes.

Install

mv ~/upgrade/parkour2 ~/
ln -s /parkour/backups ~/parkour2/misc/rsnapshot/backups
ln -s /root/pk2media ~/parkour2/media

Check that the media link points to the persistent directory, before running make prod:

readlink -f ~/parkour2/media   # MUST print /root/pk2media

Note

Our rsnapshot backups go to /parkour/backups, for that matter we're using a symbolic link ;) Media files work the same way: /root/pk2media is the permanent, persistent-across-releases directory, and ~/parkour2/media is just this release's symlink to it. rsnapshot backs up the whole media directory (see backup /data/ in misc/rsnapshot/config), so every snapshot, e.g. /parkour/backups/halfy.0/localhost/data/parkour2_media, holds a full copy of the uploads. See Backup & Restore for the media safety rules.

Config & Go LIVE!

Recommended: Edit the file misc/parkour.env.ignore to update INSTANCE_VERSION. Else, having it empty, will have it set to current date when running make prod (and reset it on new deployments.)

cp ~/pk2_old/misc/parkour.env.ignore ~/parkour2/misc/
cp ~/pk2_old/misc/migras.tar.gz ~/parkour2/misc/
cp -av ~/pk2_old/misc/*.sqldump ~/parkour2/misc/
cp ~/pk2_old/misc/*.pem ~/parkour2/misc/
sync
make --directory ~/parkour2 prod clearpy prod db-migras

Important

Check that everything looks "normal" (e.g. compare to our parkour-dev mirror.) Once everything checks, we're ready to move forward.

Also confirm the app serves media from the persistent directory and that no upload went missing:

readlink -f ~/parkour2/media                                  # /root/pk2media
find -L ~/parkour2/media -type f | wc -l                      # must equal the next line
find /root/pk2media -type f | wc -l

Warning

Migration ordering bug with old tarball: The 26.10.05 tarball's library/0015 and sample/0020 lack the dependency on request.0016_request_submitted_at. This causes make db-migras to fail on a fresh DB (column r.submitted_at does not exist).

If make prod clearpy prod db-migras fails with that error:

  1. Apply the request migrations first:
    docker compose exec parkour2-django python manage.py migrate request
  2. Re-run make --directory ~/parkour2 db-migras.

The parkour-dev box has a hand-patched tarball (migras_..._patched.tar.gz) with the missing dependency added. If you keep a patched tarball on dev, you can copy it to prod instead of the migrate request workaround. The 26.11.26 tag adds the dependency in the source, so future upgrades won't hit this.

make --directory ~/parkour2 save-postgres tar-old-migras
docker exec parkour2-rsnapshot rsnapshot halfy
date >> ~/last.txt
echo -e "SUCCESS\n\n" >> ~/last.txt
docker system prune -a -f

Note

The final tar-old-migras packs the new tag's migrations (the guide intends that the tarball and dump are a matched pair for the new release). The docker system prune -a -f deletes all unused images, including the untagged old :latest image. If you want to keep a rollback image, tag it first (see Rollback images note at the top).

The End

Just a few last things that need to be taken care of...

  • Edit the Pre-release, switch the checkboxes at bottom of that page, and make it the actual Latest release.
  • Update parkour-demo (at least once per year.)
  • If there was a new TLS certificate, check its expiration date and set a calendar reminder.
  • parkour-dev VM is running on the previous release. Fix that: bash ssh root@parkour-dev cd parkour2 make down git checkout - # server git has no `git switch`; use `git checkout -` make dev-migras dev-migras uses the dev box's own tarball (which should match its code; on dev we keep the patched tarball).
  • Develop new features, viel spaß πŸ‘πŸ½

Clone this wiki locally