Upgrade GitLab 19.5 to 19.6
This page moves an existing Cloud Pipeline deployment's cp-git from GitLab CE 19.5.3 to GitLab CE 19.6.2, the
latest released patch of GitLab 19.6 at the time of writing (checked against the
upgrade paths page and the gitlab/gitlab-ce tags on Docker Hub).
Both versions run on PostgreSQL 17, so cp-gitlab-db is not touched. See
Upgrade GitLab 15.5 to 19.5 for the procedure that got a deployment onto GitLab 19 in
the first place, and for background this page assumes: the host paths (/opt/gitlab, /opt/gitlab-postgresql),
the storage and resource risks, and the git.token rotation. This page only covers what differs for a GitLab 19
minor upgrade.
Rehearse it first, the same way as the 15.5-to-19.5 procedure: on a copy of /opt/gitlab, in an isolated
cluster, with the same image tags as the real run.
Why this is a single step
A GitLab upgrade must not skip a required upgrade stop. From GitLab 17.5 the stops fall on x.2, x.5, x.8
and x.11 of the current major version. 19.5 is a required stop, and the current deployment is already on
19.5.3, so it has passed it. The next required stop, 19.8, is not released yet. GitLab 19.6.2 sits between the
two, so there is nothing to pass through: one image swap takes cp-git straight from 19.5.3 to 19.6.2, the same
way a single stop of the 15.5-to-19.5 procedure does. If 19.8 ships before this upgrade runs, check the
upgrade paths page again: 19.8 would then be a required stop
in between.
Unlike the 15.5-to-19.5 procedure, both ends are the Cloud Pipeline git-19 image: there is no intermediate stop
on a plain gitlab/gitlab-ce image, and no PostgreSQL major-version upgrade.
What changes in 19.6
From the GitLab 19 upgrade notes:
- A background migration queued at 19.5 (
BackfillDuoWorkflowsCheckpointHeadersAndBlobs) must finish before this upgrade: a later version removes the code that reads the old table. The pre-upgrade check below (bbm) covers it, along with any other unfinished migration. - A migration bug (
DropAiEventsCounts) fails on 19.6.0 and 19.6.1 when a detached partition ofai_events_countsis still around. It is fixed in 19.6.2, which is why this page does not stop at 19.6.0 or 19.6.1. - Geo and the new NGINX buffer-size and Service Ping internal-secret changes do not apply here: this is GitLab
CE, with no Geo, and
cp-gitruns a single replica.
The GitLab Agent for Kubernetes default of a native gRPC address is a 19.5.0 change, already in effect since the deployment is already on 19.5.3: nothing more to do for it here.
Before you start
What you need
- The same root shell, tools (
kubectl,git,curl,openssl,tar) and backup directory as Upgrade GitLab 15.5 to 19.5, and the same values:git.external.url,git.token,CP_GITLAB_INTERNAL_PORT, and a pipeline repository to clone insmoke. - A Cloud Pipeline build whose
git-19image is based ongitlab/gitlab-ce:19.6.2-ce.0(deploy/docker/cp-git/Dockerfile.19.6), deployed to the registry of the deployment, under<registry prefix>lifescience/cloud-pipeline:git-19-<version>.
Session setup
Run this once. It reuses the helpers from Upgrade GitLab 15.5 to 19.5 → Session setup:
git_pod, db_pod, db_sql, db_sanity, bbm, git_stop, git_start, smoke and stop_backup. This upgrade
never stops or restarts cp-gitlab-db, so skip db_stop/db_start and the DB_USER/DB_PASS/DB_COLLATE/
DB_CTYPE variables they need.
set -o pipefail
export BKP_DIR=/mnt/gitlab-upgrade # off the file system of /opt/gitlab
export GIT_URL=https://git.example.com:443 # the git.external.url preference
export GIT_PORT=30080 # CP_GITLAB_INTERNAL_PORT
export SMOKE_REPO=root/my-pipeline # a pipeline repository, <namespace>/<project>
export DB_NAME=gitlabhq_production # GITLAB_DATABASE_DATABASE
read -rsp 'git.token: ' GIT_TOKEN; echo
export GIT_TOKEN
mkdir -p "$BKP_DIR" && chmod 700 "$BKP_DIR"
Checks that must pass
The version is 19.5.3, and smoke works.
curl -ksSf -H "PRIVATE-TOKEN: $GIT_TOKEN" "$GIT_URL/api/v4/version"
smoke
No background migration is pending (this also confirms the 19.5 Duo Agent Platform migration has finished):
bbm
kubectl exec "$(git_pod)" -- gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
The new image is there, and is exactly 19.6.2:
docker pull <registry prefix>lifescience/cloud-pipeline:git-19-<version>
docker run --rm --entrypoint cat <registry prefix>lifescience/cloud-pipeline:git-19-<version> \
/opt/gitlab/embedded/service/gitlab-rails/VERSION; echo
Freeze, back up and upgrade
Tell the users and administrators, and close GitLab, exactly as in Freeze and back up → 1. Tell the users and 2. Close GitLab. Then:
# GitLab backup and a database dump, on 19.5.3
mkdir -p "$BKP_DIR/19.5.3"
kubectl exec "$(git_pod)" -- gitlab-backup create
mv "$(ls -t /opt/gitlab/data/backups/*_gitlab_backup.tar | head -1)" "$BKP_DIR/19.5.3/"
git_stop
stop_backup 19.5.3
# Swap the image, and wait for it to come up and finish its migrations
git_start "<registry prefix>lifescience/cloud-pipeline:git-19-<version>"
while [ -n "$(bbm)" ]; do bbm; echo; sleep 60; done
kubectl exec "$(git_pod)" -- gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
cp-gitlab-db stays up throughout: GitLab 19.6 runs its migrations against it directly, the same way any
gitlab-ctl reconfigure does.
Check that GitLab works:
smoke
kubectl exec "$(git_pod)" -- gitlab-rake gitlab:git:fsck
curl -ksSf -H "PRIVATE-TOKEN: $GIT_TOKEN" "$GIT_URL/api/v4/version"
smoke must print 19.6.2, the git.token details, at least one SAML sign-in link, and the last commit of the
pipeline repository. gitlab:git:fsck must report no error.
Back up again, now on 19.6.2, and open GitLab to the users as in After the upgrade → Open GitLab:
stop_backup 19.6.2
kubectl patch svc cp-git -p '{"spec": {"selector": {"cloud-pipeline/cp-git": "true"}}}'
kubectl get endpoints cp-git
Scale the freeze's services back up, turn git.token.rotation.enabled back on, take a full backup with the
backup workers, and remove the system event — the same steps as
After the upgrade.
Roll back
cp-gitlab-db was never stopped or moved, so a rollback is just the image, the other way round:
git_stop
git_start "<registry prefix>lifescience/cloud-pipeline:git-19-<version of 19.5.3>"
smoke
If the 19.6.2 migrations already changed data in a way the old version cannot read, restore the database from the dump taken before the upgrade instead of starting 19.5.3 on the live data:
git_stop
kubectl exec -i "$(db_pod)" -- pg_restore -U postgres -d "$DB_NAME" --clean --if-exists --exit-on-error \
< "$BKP_DIR/19.5.3/$DB_NAME.dump"
echo "pg_restore exit $?"
kubectl exec "$(db_pod)" -- vacuumdb -U postgres --all --analyze-in-stages
diff "$BKP_DIR/19.5.3/sanity.txt" <(db_sanity) && echo "same"
git_start "<registry prefix>lifescience/cloud-pipeline:git-19-<version of 19.5.3>"
smoke
pg_restore --clean drops the existing tables before restoring the dump, on the same running PostgreSQL server and
role: there is no new data directory or role to create, unlike the PostgreSQL major-version upgrades of
Upgrade GitLab 15.5 to 19.5. --clean only drops what is in the dump: a table a
19.6.2 migration created after the dump was taken is not in it, so it survives the restore. Check
gitlab-rake db:migrate:status on 19.5.3 after the restore, and drop such a table by hand if one is left.
Open the cp-git service again once the rollback is checked, with the kubectl patch svc command in
Freeze, back up and upgrade.