Skip to content

Commit 2c19ef4

Browse files
searcher: stop setting cache size env vars, let searcher size its caches
The chart derived SEARCHER_CACHE_SIZE_MB and SYMBOLS_CACHE_SIZE_MB from searcher.storageSize with trimSuffix "Gi" | mul 450. Any other unit (150G, 50000Mi) rendered 0, which disables eviction and fills the volume. searcher already sizes each cache to 45% of its volume when the env vars are unset, so drop the chart-side arithmetic and the autoCacheSize knob. Admins who want a fixed size set the env vars under searcher.env. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ee04-46d0-702b-9932-65e20f260c77 Co-authored-by: Amp <amp@ampcode.com>
1 parent 09e488f commit 2c19ef4

5 files changed

Lines changed: 37 additions & 30 deletions

File tree

‎charts/sourcegraph/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Use `**BREAKING**:` to denote a breaking change
88

99
## Unreleased
1010

11+
- **BREAKING**: The chart no longer sets `SEARCHER_CACHE_SIZE_MB` and `SYMBOLS_CACHE_SIZE_MB`; `searcher` sizes each cache to 45% of its cache volume at startup. Previously the chart derived them from `searcher.storageSize` assuming a `Gi` suffix, so any other unit (e.g. `150G`) rendered `0`, which disables eviction and fills the volume. `searcher.autoCacheSize` is removed. To pin an explicit size, set the env vars under `searcher.env`
1112
- 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.
1213
- 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.
1314
- Added a `network-policy` example, which limits Executor and Executor job pods to the frontend API

‎charts/sourcegraph/README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ In addition to the documented values, all services also support the following va
403403
| redisStore.storageAnnotations | object | `{}` | Optional annotations to add to the `redis-store` PVC |
404404
| redisStore.storageSize | string | `"100Gi"` | PVC Storage Request for `redis-store` data volume |
405405
| redisStore.storageSubPath | string | `""` | Optional subPath for the `redis-store` primary data volume mount |
406-
| searcher.autoCacheSize | bool | `false` | When enabled, omit the `SEARCHER_CACHE_SIZE_MB` and `SYMBOLS_CACHE_SIZE_MB` env vars so `searcher` auto-sizes its cache to ~45% of the live cache volume. This tracks PVC expansion automatically, whereas the hardcoded env vars are frozen to the initial `storageSize` and do not follow later disk growth. |
407406
| searcher.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `searcher` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
408407
| searcher.env | object | the chart will add some default environment values | Environment variables for the `searcher` container |
409408
| searcher.image.defaultTag | string | `"6.0.0@sha256:c7508abda2202d4a33400ce23a95dd8d59fe6220d85d7fbee6fb186c55931336"` | Docker image tag for the `searcher` image |

‎charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,6 @@ spec:
5757
- name: {{ $name }}
5858
{{- $item | toYaml | nindent 10 }}
5959
{{- end }}
60-
{{- if not .Values.searcher.autoCacheSize }}
61-
# When autoCacheSize is enabled, these env vars are omitted so searcher
62-
# sizes its cache to ~45% of the live cache volume, tracking PVC
63-
# expansion automatically. SEARCHER_CACHE_SIZE_MB / SYMBOLS_CACHE_SIZE_MB
64-
# are deprecated in favor of this auto-detection.
65-
- name: SEARCHER_CACHE_SIZE_MB
66-
# Set the cache size to ~45% of the PVC size
67-
{{- if .Values.searcher.storageSize }}
68-
value: {{ trimSuffix "Gi" .Values.searcher.storageSize | mul 450 | quote }}
69-
{{- else }}
70-
# This value is ~45% of the default value for
71-
# storageSize in the VolumeClaimTemplate below
72-
value: "11700"
73-
{{- end }}
74-
- name: SYMBOLS_CACHE_SIZE_MB
75-
# Set the cache size to ~45% of the PVC size
76-
{{- if .Values.searcher.storageSize }}
77-
value: {{ trimSuffix "Gi" .Values.searcher.storageSize | mul 450 | quote }}
78-
{{- else }}
79-
# This value is ~45% of the default value for
80-
# storageSize in the VolumeClaimTemplate below
81-
value: "11700"
82-
{{- end }}
83-
{{- end }}
8460
- name: POD_NAME
8561
valueFrom:
8662
fieldRef:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
suite: searcher cache size
2+
templates:
3+
- searcher/searcher.StatefulSet.yaml
4+
tests:
5+
- it: should not set cache size env vars, searcher sizes its caches from the volume
6+
set:
7+
searcher.storageSize: 150G
8+
asserts:
9+
- notContains:
10+
path: spec.template.spec.containers[0].env
11+
content:
12+
name: SEARCHER_CACHE_SIZE_MB
13+
any: true
14+
- notContains:
15+
path: spec.template.spec.containers[0].env
16+
content:
17+
name: SYMBOLS_CACHE_SIZE_MB
18+
any: true
19+
- it: should pass through cache size env vars set under searcher.env
20+
set:
21+
searcher.env:
22+
SEARCHER_CACHE_SIZE_MB:
23+
value: "20000"
24+
SYMBOLS_CACHE_SIZE_MB:
25+
value: "1500"
26+
asserts:
27+
- contains:
28+
path: spec.template.spec.containers[0].env
29+
content:
30+
name: SEARCHER_CACHE_SIZE_MB
31+
value: "20000"
32+
- contains:
33+
path: spec.template.spec.containers[0].env
34+
content:
35+
name: SYMBOLS_CACHE_SIZE_MB
36+
value: "1500"

‎charts/sourcegraph/values.yaml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,11 +1261,6 @@ searcher:
12611261
create: false
12621262
# -- Name of the ServiceAccount to be created or an existing ServiceAccount
12631263
name: ""
1264-
# -- When enabled, omit the `SEARCHER_CACHE_SIZE_MB` and `SYMBOLS_CACHE_SIZE_MB`
1265-
# env vars so `searcher` auto-sizes its cache to ~45% of the live cache volume.
1266-
# This tracks PVC expansion automatically, whereas the hardcoded env vars are
1267-
# frozen to the initial `storageSize` and do not follow later disk growth.
1268-
autoCacheSize: false
12691264
# -- Size of the PVC for searcher pods to store cache data
12701265
storageSize: 26Gi
12711266
# -- Optional subPath for the `searcher` primary data volume mount

0 commit comments

Comments
 (0)