Repository navigation
sourcegraph: run DB permission init containers on the DB images - #997
Merged
Merged
Conversation
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>
michaellzc
approved these changes
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>
Collaborator
|
The backport to To backport this PR manually, you can either: Via the sg toolUse the sg backport -r 8.2.x -p 997Via your terminalTo 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.xIf 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
Once the pull request has been created, please ensure the following:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A customer pointed out that the chart pulls
sourcegraph/alpine-3.14for thecorrect-data-dir-permissionsinit containers onpgsql,codeintel-dbandcodeinsights-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 runssh -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.imageis removed;alpine.containerSecurityContextandalpine.resourceskeep 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 thealpine-3.14image.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.