From 710b03264f6454d45b2ad28d13a7a256ca877209 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:25:01 -0600 Subject: [PATCH] codeintel-db: keep the PVC named codeintel-db regardless of codeIntelDB.name The PVC template applied codeIntelDB.name to the claim, but the StatefulSet always references claimName codeintel-db, so setting a custom name left the pod Pending on a missing claim. Every other component hardcodes its PVC name, and values.yaml documents *.name as not affecting PVCs, so align codeintel-db with that contract. Add a helm-unittest suite asserting that a custom name on each PVC-backed component renames the workload but not its PVC or claimName. Closes #612 Amp-Thread-ID: https://ampcode.com/threads/T-01a15718-a970-736b-af0a-1b453f5ba94a Co-authored-by: Amp --- charts/sourcegraph/CHANGELOG.md | 1 + .../codeintel-db.PersistentVolumeClaim.yaml | 2 +- .../tests/componentNamePVC_test.yaml | 139 ++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 charts/sourcegraph/tests/componentNamePVC_test.yaml diff --git a/charts/sourcegraph/CHANGELOG.md b/charts/sourcegraph/CHANGELOG.md index c3a3bacc..35911316 100644 --- a/charts/sourcegraph/CHANGELOG.md +++ b/charts/sourcegraph/CHANGELOG.md @@ -8,6 +8,7 @@ Use `**BREAKING**:` to denote a breaking change ## Unreleased +- Fixed the `codeintel-db` PersistentVolumeClaim being renamed by `codeIntelDB.name`, which left the StatefulSet pointing at a `codeintel-db` claim that no longer existed and stuck the pod in `Pending`. The PVC is now always named `codeintel-db`, matching the other components and the documented behaviour of `*.name`. If you worked around this by creating a `codeintel-db` PVC by hand, label it `app.kubernetes.io/managed-by: Helm` and annotate it with `meta.helm.sh/release-name` and `meta.helm.sh/release-namespace` before upgrading so Helm can adopt it. [#612](https://github.com/sourcegraph/deploy-sourcegraph-helm/issues/612) - Added opt-in Redis config management through `redisCache.config.enabled` and `redisStore.config.enabled` (both default to `false`). Default deployments retain their image configs, custom mounts, authentication, and memory settings. When enabled, the chart mounts `/etc/redis/redis.conf` and supports `existingConfig`, `maxmemory`, `maxmemoryRatio`, `maxmemoryPolicy`, and `additionalConfig`. See [Enabling Redis config management](README.md#enabling-redis-config-management) before opting in, especially when using custom images or Secret-mounted configs. - With Redis config management enabled, the chart sizes `maxmemory` at 75% of `resources.limits.memory` to leave room for overhead; this reduces, but does not eliminate, OOM risk. Ratios must be greater than 0 and less than 1. Auto-sizing is skipped in local development mode or when the limit is absent or unrecognised. At the default 7Gi limit, opting in lowers the effective cap from 6GiB to 5.25GiB: `redis-cache` evicts earlier, but `redis-store` uses `noeviction`, so its write-error ceiling drops too. Set `redisStore.config.maxmemory: 6gb` to keep the old ceiling if the pod has sufficient memory. - `searcher.storageSize` now accepts any Kubernetes quantity (e.g. `150G`, `1Ti`, `1.5Ti`, `500000M`) when deriving `SEARCHER_CACHE_SIZE_MB` and `SYMBOLS_CACHE_SIZE_MB`. Previously anything other than `Gi` silently rendered both as `0`, which disables cache eviction and lets the cache volume fill up. Unparseable values, or values below `3M`, now fail the render unless `searcher.autoCacheSize` is enabled. The derived size now matches searcher's own auto-sizing arithmetic (45% of the volume in decimal megabytes), so existing `Gi` deployments see a slightly higher value on upgrade, e.g. the default `26Gi` renders `12562` instead of `11700`. diff --git a/charts/sourcegraph/templates/codeintel-db/codeintel-db.PersistentVolumeClaim.yaml b/charts/sourcegraph/templates/codeintel-db/codeintel-db.PersistentVolumeClaim.yaml index 391e5700..fe496da4 100644 --- a/charts/sourcegraph/templates/codeintel-db/codeintel-db.PersistentVolumeClaim.yaml +++ b/charts/sourcegraph/templates/codeintel-db/codeintel-db.PersistentVolumeClaim.yaml @@ -9,7 +9,7 @@ metadata: annotations: {{- toYaml .Values.codeIntelDB.storageAnnotations | nindent 4 }} {{- end }} - name: {{ default "codeintel-db" .Values.codeIntelDB.name }} + name: codeintel-db spec: accessModes: - ReadWriteOnce diff --git a/charts/sourcegraph/tests/componentNamePVC_test.yaml b/charts/sourcegraph/tests/componentNamePVC_test.yaml new file mode 100644 index 00000000..780eb0e3 --- /dev/null +++ b/charts/sourcegraph/tests/componentNamePVC_test.yaml @@ -0,0 +1,139 @@ +suite: component name does not rename PVCs +# `.name` renames the workload, but PVC names and the +# claimName that references them stay fixed, so the workload can +# always find its volume. +set: + blobstore: + name: custom-blobstore + codeInsightsDB: + name: custom-codeinsights-db + codeIntelDB: + name: custom-codeintel-db + pgsql: + name: custom-pgsql + prometheus: + name: custom-prometheus + redisCache: + name: custom-redis-cache + redisStore: + name: custom-redis-store +tests: +- it: should keep the blobstore PVC name and claimName fixed + templates: + - blobstore/blobstore.PersistentVolumeClaim.yaml + - blobstore/blobstore.Deployment.yaml + asserts: + - equal: + path: metadata.name + value: blobstore + template: blobstore/blobstore.PersistentVolumeClaim.yaml + - equal: + path: metadata.name + value: custom-blobstore + template: blobstore/blobstore.Deployment.yaml + - equal: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + value: blobstore + template: blobstore/blobstore.Deployment.yaml +- it: should keep the codeinsights-db PVC name and claimName fixed + templates: + - codeinsights-db/codeinsights-db.PersistentVolumeClaim.yaml + - codeinsights-db/codeinsights-db.StatefulSet.yaml + asserts: + - equal: + path: metadata.name + value: codeinsights-db + template: codeinsights-db/codeinsights-db.PersistentVolumeClaim.yaml + - equal: + path: metadata.name + value: custom-codeinsights-db + template: codeinsights-db/codeinsights-db.StatefulSet.yaml + - equal: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + value: codeinsights-db + template: codeinsights-db/codeinsights-db.StatefulSet.yaml +- it: should keep the codeintel-db PVC name and claimName fixed + templates: + - codeintel-db/codeintel-db.PersistentVolumeClaim.yaml + - codeintel-db/codeintel-db.StatefulSet.yaml + asserts: + - equal: + path: metadata.name + value: codeintel-db + template: codeintel-db/codeintel-db.PersistentVolumeClaim.yaml + - equal: + path: metadata.name + value: custom-codeintel-db + template: codeintel-db/codeintel-db.StatefulSet.yaml + - equal: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + value: codeintel-db + template: codeintel-db/codeintel-db.StatefulSet.yaml +- it: should keep the pgsql PVC name and claimName fixed + templates: + - pgsql/pgsql.PersistentVolumeClaim.yaml + - pgsql/pgsql.StatefulSet.yaml + asserts: + - equal: + path: metadata.name + value: pgsql + template: pgsql/pgsql.PersistentVolumeClaim.yaml + - equal: + path: metadata.name + value: custom-pgsql + template: pgsql/pgsql.StatefulSet.yaml + - equal: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + value: pgsql + template: pgsql/pgsql.StatefulSet.yaml +- it: should keep the prometheus PVC name and claimName fixed + templates: + - prometheus/prometheus.PersistentVolumeClaim.yaml + - prometheus/prometheus.Deployment.yaml + asserts: + - equal: + path: metadata.name + value: prometheus + template: prometheus/prometheus.PersistentVolumeClaim.yaml + - equal: + path: metadata.name + value: custom-prometheus + template: prometheus/prometheus.Deployment.yaml + - equal: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + value: prometheus + template: prometheus/prometheus.Deployment.yaml +- it: should keep the redis-cache PVC name and claimName fixed + templates: + - redis/redis-cache.PersistentVolumeClaim.yaml + - redis/redis-cache.Deployment.yaml + asserts: + - equal: + path: metadata.name + value: redis-cache + template: redis/redis-cache.PersistentVolumeClaim.yaml + - equal: + path: metadata.name + value: custom-redis-cache + template: redis/redis-cache.Deployment.yaml + - equal: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + value: redis-cache + template: redis/redis-cache.Deployment.yaml +- it: should keep the redis-store PVC name and claimName fixed + templates: + - redis/redis-store.PersistentVolumeClaim.yaml + - redis/redis-store.Deployment.yaml + asserts: + - equal: + path: metadata.name + value: redis-store + template: redis/redis-store.PersistentVolumeClaim.yaml + - equal: + path: metadata.name + value: custom-redis-store + template: redis/redis-store.Deployment.yaml + - equal: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + value: redis-store + template: redis/redis-store.Deployment.yaml