Skip to content

Commit 090121f

Browse files
databases: run permission init containers on the DB images (#506)
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>
1 parent 3c3be20 commit 090121f

11 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ spec:
2626
spec:
2727
initContainers:
2828
- name: correct-data-dir-permissions
29-
image: index.docker.io/sourcegraph/alpine-3.14:8.1.2687@sha256:1e113d9625cee4d32b995bb199ca7d6b6f5db1907404acc8ce9b272d39714963
29+
image: index.docker.io/sourcegraph/postgresql-16-codeinsights:8.1.2687@sha256:b7e2df5a6a63e323987eeaca23fe9f05278d4c97f96f1994b89dac3c60dedcd3
3030
command: ["sh", "-c", "if [ -d /var/lib/postgresql/data/pgdata ]; then chmod 750 /var/lib/postgresql/data/pgdata; fi"]
3131
volumeMounts:
3232
- mountPath: /var/lib/postgresql/data/

‎base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ spec:
2727
spec:
2828
initContainers:
2929
- name: correct-data-dir-permissions
30-
image: index.docker.io/sourcegraph/alpine-3.14:8.1.2687@sha256:1e113d9625cee4d32b995bb199ca7d6b6f5db1907404acc8ce9b272d39714963
30+
image: index.docker.io/sourcegraph/postgresql-16:8.1.2687@sha256:cc810cd21f1df7776aa270f49bdd50a4ec3375623ffae1f0238c20dec054bf03
3131
command: ["sh", "-c", "if [ -d /data/pgdata-12 ]; then chmod 750 /data/pgdata-12; fi"]
3232
volumeMounts:
3333
- mountPath: /data

‎base/sourcegraph/pgsql/pgsql.StatefulSet.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ spec:
2727
spec:
2828
initContainers:
2929
- name: correct-data-dir-permissions
30-
image: index.docker.io/sourcegraph/alpine-3.14:8.1.2687@sha256:1e113d9625cee4d32b995bb199ca7d6b6f5db1907404acc8ce9b272d39714963
30+
image: index.docker.io/sourcegraph/postgresql-16:8.1.2687@sha256:cc810cd21f1df7776aa270f49bdd50a4ec3375623ffae1f0238c20dec054bf03
3131
command: ["sh", "-c", "if [ -d /data/pgdata-12 ]; then chmod 750 /data/pgdata-12; fi"]
3232
volumeMounts:
3333
- mountPath: /data

‎components/utils/migrate-to-nonprivileged/blobstore/blobstore.Deployment.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
spec:
88
initContainers:
99
- name: transfer-file-ownership
10-
image: index.docker.io/sourcegraph/alpine-3.14
10+
image: index.docker.io/sourcegraph/postgresql-16
1111
command: ["sh", "-c", "chown -R 100:101 /data"]
1212
volumeMounts:
1313
- mountPath: /data

‎components/utils/migrate-to-nonprivileged/gitserver/gitserver.StatefulSet.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
spec:
88
initContainers:
99
- name: transfer-file-ownership
10-
image: index.docker.io/sourcegraph/alpine-3.14:insiders
10+
image: index.docker.io/sourcegraph/postgresql-16
1111
command:
1212
[
1313
"sh",

‎components/utils/migrate-to-nonprivileged/grafana/grafana.StatefulSet.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
spec:
88
initContainers:
99
- name: transfer-file-ownership
10-
image: index.docker.io/sourcegraph/alpine-3.14
10+
image: index.docker.io/sourcegraph/postgresql-16
1111
command: ["sh", "-c", "chown -R 472:472 /var/lib/grafana"]
1212
volumeMounts:
1313
- mountPath: /var/lib/grafana

‎components/utils/migrate-to-nonprivileged/indexed-search/indexed-search.StatefulSet.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
spec:
88
initContainers:
99
- name: transfer-file-ownership
10-
image: index.docker.io/sourcegraph/alpine-3.14
10+
image: index.docker.io/sourcegraph/postgresql-16
1111
command: ["sh", "-c", "chown -R 100:101 /data"]
1212
volumeMounts:
1313
- mountPath: /data

‎components/utils/migrate-to-nonprivileged/prometheus/prometheus.Deployment.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
spec:
88
initContainers:
99
- name: transfer-file-ownership
10-
image: index.docker.io/sourcegraph/alpine-3.14:insiders
10+
image: index.docker.io/sourcegraph/postgresql-16
1111
command: ["sh", "-c", "chown -R 100:100 /prometheus"]
1212
volumeMounts:
1313
- mountPath: /prometheus

‎components/utils/migrate-to-nonprivileged/redis/redis-cache.Deployment.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
spec:
88
initContainers:
99
- name: transfer-file-ownership
10-
image: index.docker.io/sourcegraph/alpine-3.14:insiders
10+
image: index.docker.io/sourcegraph/postgresql-16
1111
command: ["sh", "-c", "chown -R 999:1000 /redis-data"]
1212
volumeMounts:
1313
- mountPath: /redis-data

‎components/utils/migrate-to-nonprivileged/redis/redis-store.Deployment.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
spec:
88
initContainers:
99
- name: transfer-file-ownership
10-
image: index.docker.io/sourcegraph/alpine-3.14:insiders
10+
image: index.docker.io/sourcegraph/postgresql-16
1111
command: ["sh", "-c", "chown -R 999:1000 /redis-data"]
1212
volumeMounts:
1313
- mountPath: /redis-data

0 commit comments

Comments
 (0)