Skip to content

searcher: accept storageSize in G as well as Gi for cache sizing - #948

Open
marcleblanc2 wants to merge 1 commit into
mainfrom
searcher-storagesize-g-units
Open

marcleblanc2 wants to merge 1 commit into
mainfrom
searcher-storagesize-g-units

Conversation

@marcleblanc2

Copy link
Copy Markdown
Contributor

Problem

SEARCHER_CACHE_SIZE_MB and SYMBOLS_CACHE_SIZE_MB were derived with trimSuffix "Gi" .Values.searcher.storageSize | mul 450. A storageSize in any other unit (e.g. 150G) left a non-numeric string that sprig's mul cast to 0, so both env vars rendered as "0".

searcher treats 0 as "never evict" (cache_evicter.go), and since "0" counts as explicitly set (config.go) the 45% auto-sizing from sourcegraph/sourcegraph#10040 never kicks in either. Both caches grow unbounded until the PVC fills and the pod fails to start:

failed to setup TMPDIR: mkdir /mnt/cache/searcher-0/.searcher.tmp/tmpfriend-...: no space left on device

Seen on a customer instance with searcher.storageSize: 150G after upgrading 6.5.0 → 7.2.0. The template has behaved this way since #677, so the disk had been filling for months; the upgrade restart just exposed it.

Fix

  • New sourcegraph.searcher.cacheSizeMB helper accepts a whole number of G or Gi and multiplies by 450 (45% of the volume, treating 1 Gi ≈ 1000 MB as before, so existing Gi values render identically).
  • Any other unit fails the render with a pointer to searcher.autoCacheSize=true, instead of silently disabling eviction.
  • Both env blocks in searcher.StatefulSet.yaml call the helper; the default 26Gi still renders 11700.
  • values.yaml comment, README (helm-docs), CHANGELOG, and a new searcherCacheSize_test.yaml unittest suite.

Verification

helm unittest -q charts/sourcegraph   # 29 suites, 142 tests passed
helm lint charts/sourcegraph
searcher.storageSize before after
(default 26Gi) 11700 11700
100Gi 45000 45000
150G 0 (no eviction) 67500
1Ti 0 (no eviction) render fails
1Ti + autoCacheSize: true env vars omitted env vars omitted

Note: scripts/helm-docs.sh downloads an x86_64 helm-docs 1.7.0 that does not run on Apple Silicon; README was regenerated with helm-docs 1.14.2 and the diff limited to the searcher.storageSize row.

SEARCHER_CACHE_SIZE_MB and SYMBOLS_CACHE_SIZE_MB were derived with
trimSuffix "Gi" | mul 450, so a storageSize like 150G left a non-numeric
string that sprig cast to 0. searcher treats 0 as "never evict", so both
caches grew unbounded until the PVC filled and the pod failed to start with
"failed to setup TMPDIR: ... no space left on device".

Move the math into a sourcegraph.searcher.cacheSizeMB helper that accepts a
whole number of G or Gi and fails the render on anything else, unless
searcher.autoCacheSize is enabled (env vars are omitted in that case).

Amp-Thread-ID: https://ampcode.com/threads/T-01a0ca05-5e6e-769c-9aec-5f4e207ddb9b
Co-authored-by: Amp <amp@ampcode.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant