Skip to content

databases: run permission init containers on the DB images - #506

Merged
michaellzc merged 1 commit into
mainfrom
k/db-image-init-containers
Nov 12, 2026
Merged

michaellzc merged 1 commit into
mainfrom
k/db-image-init-containers

Conversation

@keegancsmith

@keegancsmith keegancsmith commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

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).

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

@michaellzc michaellzc added the backport 8.2.x Backport to 8.2.x release branch label Nov 12, 2026
The correct-data-dir-permissions init containers on pgsql, codeintel-db
and codeinsights-db used sourcegraph/alpine-3.14, a frozen 2023 build of
an Alpine release that went end-of-life in May 2023. 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. Releases already pin
those images, so the init container stays patched with them.

The migrate-to-nonprivileged component copies the pgsql init container
image into its chown init containers, so it now uses postgresql-16 too.
Its busybox provides the same sh, stat and chown.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1c5fe-5015-76c2-bf19-d42868d2b979
Co-authored-by: Amp <amp@ampcode.com>
@michaellzc
michaellzc force-pushed the k/db-image-init-containers branch from 778448a to c579543 Compare November 12, 2026 19:47
@michaellzc
michaellzc enabled auto-merge (squash) November 12, 2026 19:48
@michaellzc
michaellzc merged commit 090121f into main Nov 12, 2026
4 checks passed
michaellzc added a commit to sourcegraph/deploy-sourcegraph-helm that referenced this pull request Nov 13, 2026
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.

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Michael Lin <michael.lin@sourcegraph.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 8.2.x Backport to 8.2.x release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants