Upgrading a Docker 4.0.0 installation to 4.0.1
4.0.1 is a patch release containing no database migrations. On Docker the upgrade is a code update, a dependency sync and a restart:
git fetchandgit pulldocker compose builddocker compose up -dmanage.py checkandmanage.py migrateinside the container
You never name a version. The installation guide checks out the releases/4.0
branch rather than a version tag, so the branch carries each patch as it is released
and a git pull is all that moves you between them.
These steps apply to any 4.0.x patch, not only this one. What changes between patches is in the next section.
Note
Docker hosting is supported on Linux only. If your Docker site runs on a
Windows computer (with Docker Desktop, for example), that is no longer tested
or supported. Plan to move it to a Linux server: make a backup, set up
QATrack+ on the new server, and restore it there, as
Backing up and restoring describes. Bring your .env with you, with your
secret key copied into it (see Keep your users signed in (optional)), so
nobody is signed out by the move.
Note
The service and scheduled task names stopped carrying version numbers in 4.0.0 precisely so that patch upgrades would not require renaming anything. If you upgraded to 4.0.0 from v3.x, your service is called QATrack+ Web Service and your scheduled task QATrack+ Django Q Cluster.
Before you start
Back up your database, your qatrack/media folder and your local_settings.py,
as you would for any upgrade.
Finish or discard any QC session you have part-way through, before you upgrade. An autosaved session that straddles an upgrade is not guaranteed to come back exactly as you left it, and QATrack+ does not promise that it will.
Why, and what it means for you
An autosave holds the values a person had typed but not yet submitted. Dates among them are stored as the text that was on screen, in whatever format the site displayed at the time, so a release that changes how dates are displayed changes how that text has to be read.
4.0.2 does convert them where it can: an autosave written in the format earlier 4.0.x releases displayed is re-read and converted on load. Where a value cannot be read in any format the site now accepts, the field comes up empty and has to be typed again - which is deliberate, because an empty field can be seen and corrected while a plausible wrong date cannot.
Nothing already submitted is affected. Saved QC sessions, test list instances, service events and faults are stored as dates, not as text, and no upgrade changes them. This is only about sessions nobody has finished.
This is not something the project plans to guarantee. Making in-flight
autosaves survive every upgrade would mean versioning the autosave payload and
migrating it, for data that is transient by design - it is discarded after
AUTOSAVE_DAYS_TO_KEEP days, 30 by default. The effort is better spent
elsewhere, and the practical answer is the one at the top of this note: submit or
abandon what is in progress before upgrading.
Check that your existing backups contain a database
Before this release manage.py backup_site skipped the database on MySQL -
and on any engine it does not implement - while still reporting success. A backup
set could therefore hold media and settings and no database at all.
Look inside your most recent backup before relying on it. For MySQL, use
mysqldump.
From 4.0.1 the command names the engine it cannot handle rather than passing silently - but it still exits zero, so anything scheduled around its exit status cannot tell the difference. Check the output, or check that a database file is there.
It writes a database backup on SQL Server and SQLite only. PostgreSQL is not
one of them: the command has always reported that it cannot, so if your
PostgreSQL site has been relying on it, check now. Use pg_dump, or the
Docker backup script, which does.
What needs your attention in this release
Most of 4.0.1 is bug fixes that need nothing from you. These four do:
Python 3.12 and Django 4.2.30 or newer are now required. The Django floor was
raised for its security fixes and Python is pinned to 3.12. uv sync below
installs the right versions; you do not need to change anything by hand.
If you deploy with Docker, check your backup environment variables. The backup
script now reads POSTGRES_DB, POSTGRES_USER and POSTGRES_PASSWORD from
the environment instead of having the database name and user written into it. These
are the same variables the postgres service already uses, so a deployment that
sets them in its .env needs no change. One that had customised the hard-coded
values was previously dumping the wrong database, or nothing — confirm your next
backup contains what you expect.
If you deploy with Docker, you may now set CSRF_TRUSTED_ORIGINS from the
environment. It falls back to ALLOWED_HOSTS when not given. See the comments in
deploy/docker/.env.example.
The installfixtures management command has been removed. It loaded a
fixture set that no longer matched the schema. If you called it from a script, use
manage.py loaddata with the fixtures you want instead.
Changes to local_settings.py
Nothing in this release requires a change to local_settings.py. Your existing
file keeps working. There is one thing to check and two new settings you may want.
Remove LOGIN_EXEMPT_URLS if your local_settings.py sets it
Warning
This is the one item on this page with a security consequence. Setting
LOGIN_EXEMPT_URLS replaces the shipped list rather than adding to it, so your
copy overrides the corrected one and keeps whatever fault it was copied with.
If the setting appears in your local_settings.py , delete the whole
assignment unless you deliberately need entries of your own. The shipped default is
correct as of 4.0.1, and removing your copy means you also receive any future
correction.
Two older values are worth recognising, because both are worse than the current default:
# the commented example the installation templates carried from 2018
LOGIN_EXEMPT_URLS = [r"^qatrack/accounts/", r"qatrack/api/*"]
# the shipped default before 4.0.1
LOGIN_EXEMPT_URLS = [r"^favicon.ico$", r"^accounts/", r"api/*", r"^oauth2/*", r"^i18n/"]
These are regular expressions, not globs. api/* reads as api followed by zero
or more slashes, so it also exempts apifoo, api_secret and anything else merely
beginning with those three letters. ^favicon.ico$ leaves the . unescaped, matching
any character. The 2018 example additionally carries a qatrack/ prefix that no longer
matches anything, and omits four entries the current default has — so a site using it
requires a login for its favicon, OAuth2 and both translation catalogues.
If you do need your own entries, add them to a copy of the current default rather than an older one:
LOGIN_EXEMPT_URLS = [
r"^favicon\.ico$",
r"^accounts/",
r"^api(/|$)",
r"^oauth2(/|$)",
r"^i18n/",
r"^jsi18n/",
# your own entries here
]
See Configuring a QATrack+ Installation for the full explanation.
Two new settings, both optional
LANGUAGE_COOKIE_AGE sets how long a user’s language choice is remembered. It
now defaults to one year; before this release the cookie had no explicit lifetime, so
it expired with the browser session and the interface reverted to the default language
on the next visit. To shorten it:
LANGUAGE_COOKIE_AGE = 30 * 24 * 60 * 60 # 30 days
CSRF_TRUSTED_ORIGINS may now be set from the environment, which is mainly of
interest to Docker deployments. When the CSRF_TRUSTED_ORIGINS environment variable
is set it is read as a comma-separated list; when it is not, it is derived from
ALLOWED_HOSTS. You can still set it directly in local_settings.py if you prefer.
See the comments in deploy/docker/.env.example.
Before you pull: check your Docker Compose version
From 4.0.2, QATrack+ needs Docker Compose 2.17 or newer and Docker Engine
23.0 or newer (see Minimum Docker versions for why). Check both before
git pull:
docker compose version
docker version --format '{{.Server.Version}}'
With an older Compose, once you have pulled, every command that builds or creates
containers stops: up, build, run (so restore-media too), create
and pull, as well as config. The error looks like this:
services.django.build Additional property additional_contexts is not allowed
Your current containers aren’t affected: they keep running. But every other
docker compose command stops with the same error, ps, logs,
exec, stop, start, restart and down included, unless you add
-p qatrackplus (for example, docker compose -p qatrackplus logs django).
You can’t build or start 4.0.2 until Docker is updated, and if you run
docker compose down in the meantime, up can’t create the containers
again, so your site stays down until then.
If either version is too old, update Docker first (on Ubuntu, through Docker’s apt
repository, which updates the Engine and the docker-compose-plugin package
together), then carry on with the upgrade. If you have already pulled and see that
error, updating Docker is the fix too: nothing else needs undoing.
Upgrading from 4.0.0 or 4.0.1: keep your .env
From 4.0.2, deploy/docker/.env is no longer part of the QATrack+ repository,
because it holds your database password. Your copy has your own settings in it, so
on this one upgrade git pull stops with Your local changes to the following
files would be overwritten. Before the first pull to 4.0.2 or later, set your
.env aside and put it back afterwards:
cd ~/web/qatrackplus
cp deploy/docker/.env ../qatrack.env.backup
git checkout -- deploy/docker/.env
git stash push -m qatrack-4.0.2-upgrade
git branch --show-current
git checkout releases/4.0 # only if the line above printed something else
git pull
git stash list | grep -q qatrack-4.0.2-upgrade && git stash pop
cp ../qatrack.env.backup deploy/docker/.env
The branch check belongs here, in the middle of those commands, and not after
them. An installation made before 4.0.2 was told to clone without naming a
branch, so it sits on master - where git pull answers Already up to
date and moves nothing, because master is still at the release before this
one. The switch to releases/4.0 is what actually brings the new code, and it
only works while your .env is set aside: with .env back in place it is a
modified tracked file again, and git checkout releases/4.0 stops with Your
local changes to the following files would be overwritten by checkout. A site
already on releases/4.0 can leave the checkout line out; the git pull
then does the work, as it does for every later patch.
git stash and git stash pop keep any other changes you have made to
QATrack+’s files, such as a different port in deploy/docker/compose.yaml or
edits to nginx.conf. 4.0.2 changes compose.yaml and the nginx files for
the first time since 4.0.0, so without these steps git pull stops on any of
them you have changed. If git stash replies No local changes to save, that’s fine:
the grep line then skips git stash pop, so an older stash you may have is
left alone. If it asks
Please tell me who you are, tell git once, then run git stash again:
git config user.name "QATrack+ administrator"
git config user.email "you@example.com"
If you edited deploy/docker/nginx/conf.d/default.conf, for example to set up
HTTPS, git stash pop reports a conflict on it and keeps your stash. 4.0.2 no
longer uses that file: nginx is now configured from .env (see
Serving QATrack+ over HTTPS). Save your old copy to compare with, then finish the step:
git show 'stash@{0}:deploy/docker/nginx/conf.d/default.conf' > ../old-nginx-default.conf
git rm -q deploy/docker/nginx/conf.d/default.conf
git reset -q
git status
Before you go on, check what git status lists. If any other file shows a
conflict, most likely deploy/docker/compose.yaml, open it and resolve the
section between the <<<<<<< and >>>>>>> markers by hand, keeping your
change and 4.0.2’s. git stash show -p 'stash@{0}' shows every change you had
stashed. Only once all of them are back in place, and no conflict markers are
left, remove the stash - by its reference, not as a bare drop:
git stash drop 'stash@{0}'
Only run that if git stash pop reported a conflict. A pop that succeeded
has already removed the stash, and a bare git stash drop would then delete
whatever stash is now on top - which may be work of yours from weeks ago. If
git stash list no longer shows qatrack-4.0.2-upgrade, there is nothing to
drop and you can skip this.
Your other changes stay in place.
Your .env is now ignored by git, and later pulls leave it alone. Compare it
with deploy/docker/.env.example, which lists every setting you can now make
there: in particular set ALLOWED_HOSTS to the names people use to reach
QATrack+. Keep qatrack.env.backup somewhere safe, or delete it: it holds your
database password.
If your server is a Windows machine, see the note on line endings in the installation guide as well.
Confirm you are on the release branch
Installations made before 4.0.2 were told to git clone without naming a branch, which
leaves the checkout on master rather than on a release. git pull then follows
master, so the site can pick up work that has not been released, and a patch release
never arrives at all. The switch above is what moves an existing installation onto the
branch, once. Confirm it took:
cd ~/web/qatrackplus
git branch --show-current
releases/4.0 is the whole check. If it still prints master, the checkout line
above was skipped or stopped on a modified file: read what git status lists, set aside
anything of yours it names as the .env steps do, and run the checkout again.
Note
manage.py and the admin report the version from qatrack/settings.py, which is
set by hand. A checkout of master therefore reports a release number too, so the
branch name is the only thing that tells you which code you are running.
Keep your users signed in (optional)
From 4.0.2, QATrack+ keeps its secret key in a Docker volume, or takes it from
SECRET_KEY in .env. 4.0.0 and 4.0.1 kept it in your QATrack+ folder, at
deploy/docker/user-data/secret_key.txt. If you start 4.0.2 without carrying it
over, QATrack+ makes a new key: every user is signed out once, and password-reset
links sent before the upgrade stop working.
To keep the key, copy it into .env before you start 4.0.2 for the first time:
cd ~/web/qatrackplus
printf '\nSECRET_KEY=%s\n' "$(cat deploy/docker/user-data/secret_key.txt)" >> deploy/docker/.env
If that file does not exist, there is no key to carry over; skip this step.
QATrack+ then generates a key and keeps it in a Docker volume that the nightly
backup does not include: Keeping the secret key safe shows how to copy it into
.env too. The key signs your users’ sessions: keep .env as private as
your database password.
Clear follow-up emails that were never sent (optional)
Docker installations before 4.0.2 did not run QATrack+’s background tasks, so the follow-up emails of QC Completed notices set to Follow up were queued but never sent. 4.0.2 runs background tasks, and the first time it starts it sends every follow-up still waiting, all at once, however old. Only sites that set up follow-up notices are affected.
While your current QATrack+ is still running, and before docker compose up -d
starts 4.0.2, see how many are waiting:
cd ~/web/qatrackplus/deploy/docker
docker compose exec -T django python manage.py shell -c "from django.utils import timezone; from django_q.models import Schedule; print(Schedule.objects.filter(name__startswith='follow-up-for-tli-', schedule_type=Schedule.ONCE, next_run__lt=timezone.now()).exclude(repeats=0).count(), 'overdue follow-up emails')"
To remove them instead of sending them:
docker compose exec -T django python manage.py shell -c "from django.utils import timezone; from django_q.models import Schedule; print(Schedule.objects.filter(name__startswith='follow-up-for-tli-', schedule_type=Schedule.ONCE, next_run__lt=timezone.now()).exclude(repeats=0).delete()[0], 'overdue follow-up emails removed')"
Follow-ups that are not due yet are kept, and are sent on time.
Running the upgrade
From your deploy/docker directory:
cd ~/web/qatrackplus
git fetch origin
git pull
cd deploy/docker
docker compose build
docker compose up -d
Then check the installation and run the migration step inside the container:
docker compose exec django python manage.py check
docker compose exec django python manage.py migrate
Before restarting, re-read What needs your attention in this release above: the backup script’s environment variables changed in this release.
Note
manage.py check reports configuration problems, not data problems — it will not
tell you whether your backups contain a database or whether your groups have the
permissions they need. Both are covered below.
After upgrading
Check your group permissions, once, if any group was created in v3.x. Under Authentication and Authorization → Groups, confirm that wherever a group has Can change X it also has Can view X.
Why those groups are missing it
Django added a separate view permission per model in version 2.1, so groups set
up before that have change without it. The admin hides this, because Django
treats change as implying view — but some admin widgets check for view
alone, and refuse the request that fills the field in.
What this will not fix
If a Test List’s memberships show a test’s ID and macro name but no test name, group permissions are not the cause and granting them will change nothing. That is a separate fault, reported as #897 and present in every 4.0 release up to and including this one: the admin answers the request that fetches the name with a 404 before any permission is considered, so it fails for every user including a superuser. A fix is in hand for a later release.
The permission check above is still worth doing - it is a real cause of a blank field in other places, and it costs one look at your groups - but do not expect it to restore a missing test name.
Confirm your backups — if you act on one thing in this release, make it the backup check at the top of this page. It applies to MySQL and to PostgreSQL, for different reasons.