Skip to content

sourcegraph: run DB permission init containers on the DB images - #997

Merged
michaellzc merged 2 commits into
mainfrom
k/db-image-init-containers
Nov 13, 2026
Merged

michaellzc merged 2 commits into
mainfrom
k/db-image-init-containers

Conversation

@keegancsmith

@keegancsmith keegancsmith commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

A customer pointed out that the chart pulls sourcegraph/alpine-3.14 for the correct-data-dir-permissions init containers on pgsql, codeintel-db and codeinsights-db. Alpine 3.14 went end-of-life in May 2023, and the image is worse than its name suggests: the monorepo pins its base to a November 2023 build and only re-tags it each release, so it still ships OpenSSL 1.1.1t, curl 8.4.0 and friends. The init container only runs sh -c chmod, which the database images already provide (busybox), so it now runs on the same image as the database container. The chart no longer references alpine at all, and there's nothing extra to pull or mirror.

alpine.image is removed; alpine.containerSecurityContext and alpine.resources keep their names so existing overrides (e.g. the OpenShift example) still apply. Kustomize gets the same change in sourcegraph/deploy-sourcegraph-k8s#506. Once both land, sourcegraph/sourcegraph#18714 retires the alpine-3.14 image.

Manually tested on kind: deployed the three databases from main, wrote a row and loosened each data dir to 0777, then applied this branch. The init containers completed on the postgres images, the data dirs came back as 0700, and the data survived. A fresh install also came up cleanly.

The correct-data-dir-permissions init containers on pgsql, codeintel-db
and codeinsights-db used sourcegraph/alpine-3.14, which is a frozen 2023
build of an Alpine release that went end-of-life in May 2023 and gets
flagged by image scanners. The init container only needs sh and chmod,
which the database images already ship, so run it on the same image as
the database container. That drops an image from the chart entirely and
keeps the init container patched with each release.

alpine.containerSecurityContext and alpine.resources keep their names so
existing overrides, such as the OpenShift example, still apply.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1c5fe-5015-76c2-bf19-d42868d2b979
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

@keegancsmith
keegancsmith marked this pull request as ready for review November 12, 2026 13:50
@keegancsmith
keegancsmith requested a review from a team November 12, 2026 13:58
@michaellzc michaellzc added the backport 8.2.x Backport to 8.2.x release branch label Nov 12, 2026
Resolve conflicts in charts/sourcegraph/CHANGELOG.md (keep both sets of
entries) and charts/sourcegraph/values.yaml (keep the removal of
alpine.image, dropping main's re-pinned alpine-3.14 tag).

Amp-Thread-ID: https://ampcode.com/threads/T-d0ec393a-2cee-490c-add7-6ea9af2c782e
Co-authored-by: Amp <amp@ampcode.com>
michaellzc pushed a commit to sourcegraph/deploy-sourcegraph-k8s that referenced this pull request Nov 12, 2026
The `correct-data-dir-permissions` init containers on `pgsql`,
`codeintel-db` and `codeinsights-db` pull `sourcegraph/alpine-3.14`,
which is a frozen November 2023 build of an Alpine release that went
end-of-life in May 2023 (OpenSSL 1.1.1t, curl 8.4.0, ...), and
customers' scanners rightly flag it. The init container only runs `sh -c
chmod`, which the database images already have via busybox, so it now
uses the same pinned image as the database container. The
`migrate-to-nonprivileged` component copies the pgsql init container
image into its chown init containers, so those now get `postgresql-16`,
whose busybox has the same `sh`, `stat` and `chown`. Afterwards nothing
in this repo references alpine.

Sister change in Helm: sourcegraph/deploy-sourcegraph-helm#997. Docker
Compose doesn't use the image. Once both land,
sourcegraph/sourcegraph#18714 retires the `alpine-3.14` image.

Test plan: rendered every example overlay before and after; the only
diff is the three init container images. With `migrate-to-nonprivileged`
included, all its init containers resolve to the pinned `postgresql-16`.
Ran the gitserver/searcher chown command from that component as root in
`postgresql-16`. `.buildkite/check-image-names.sh` passes. The same init
container change in Helm was exercised end to end on kind (upgrade from
main with existing data, and fresh install).

Co-authored-by: Amp <amp@ampcode.com>
@michaellzc
michaellzc merged commit 2004a04 into main Nov 13, 2026
6 checks passed
@michaellzc
michaellzc deleted the k/db-image-init-containers branch November 13, 2026 00:17
@sourcegraph-release-bot

Copy link
Copy Markdown
Collaborator

The backport to 8.2.x failed at https://github.com/sourcegraph/deploy-sourcegraph-helm/actions/runs/43335875375:

The process '/usr/bin/git' failed with exit code 1

To backport this PR manually, you can either:

Via the sg tool

Use the sg backport command to backport your commit to the release branch.

sg backport -r 8.2.x -p 997
Via your terminal

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.2.x 8.2.x
# Navigate to the new working tree
cd .worktrees/backport-8.2.x
# Create a new branch
git switch --create backport-997-to-8.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 2004a0402bc704e5443ee38016852aeeced73b6a
# Push it to GitHub
git push --set-upstream origin backport-997-to-8.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.2.x

If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:

git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-997-to-8.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.2.x
  • Follow above instructions to backport the commit.
  • Create a pull request where the base branch is 8.2.x and the compare/head branch is backport-997-to-8.2.x., click here to create the pull request.

Once the pull request has been created, please ensure the following:

  • Make sure to tag @sourcegraph/release in the pull request description.

  • kindly remove the release-blocker from this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants