Repository navigation
Standardize health probes with shared helpers - #971
Draft
marcleblanc2 wants to merge 1 commit into
Draft
marcleblanc2 wants to merge 1 commit into
marcleblanc2 wants to merge 1 commit into
Conversation
Add sourcegraph.probes, sourcegraph.httpProbes, sourcegraph.postgresProbes, and sourcegraph.redisProbes under templates/_helpers, and use them for every probed container in the chart. Each container gets a startup probe that holds liveness and readiness off until it passes, a liveness probe that restarts after 30s of failures, and a readiness probe every 5s. Add sourcegraph.startupDeadlineSeconds (default 300) with a per-service <serviceName>.startupDeadlineSeconds override; the Postgres databases and prometheus default to 3600 for crash recovery, upgrades, and WAL replay. Add the missing probes to codeinsights-db, a liveness probe to searcher, cadvisor, prometheus, jaeger, and zoekt-indexserver, and liveness and readiness probes to grafana. Probe blobstore on its debug port instead of the S3 API root. Fixes #296 Co-authored-by: Amp <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-01a1572b-fce8-7159-abd5-f4142c8f68a2
marcleblanc2
marked this pull request as draft
November 13, 2026 10:48
This branch has not been deployed
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.
Open issues
Found in review on 2026-11-13 (review thread), at
85af304. The first one takes blobstore down on every install; this PR is a draft until the first three are fixed.sourcegraph/blobstoreimage is s3proxy (Java), not asvcmainbinary, and listens only on 9000. Reproduced on EKS: after the upgrade nothing answered on:6060/readywhile:9000/returned 200, the pod stayed 0/1, the kubelet killed the container at 300 s ("failed startup probe, will be restarted"), and theblobstoreService had no ready endpoint. Fix: keep the old target withsourcegraph.httpProbeson porthttp, path/; drop thehttp-debugport; correct the test, the changelog, and the "Behaviour changes" text belowhelm upgrade --reuse-valuesgives every startup probe a 3 second budget. The stored values have nostartupDeadlineSeconds, sofailureThresholdrenders empty and Kubernetes uses 3, at a 1 second period. A dry run of that upgrade against the live release rendered 18 startup probes this way, the three databases included; it was not applied.startupDeadlineSeconds: nullor0in an override does the same. Fix: fall back to 300 (3600 for Postgres and prometheus) in the helper when the value is missing, and add a testmainincharts/sourcegraph/CHANGELOG.md. Everything else merges cleanly. Fix: rebase and keep both sidesmainalready hasindexedSearch.livenessProbeandreadinessProbevalues for zoekt-webserver. The zoekt-indexserver probe is the risky one:/debugis served by the process that indexes, so a busy indexer that answers slowly is killed mid-job. That was not observed; the indexer here was idle. Fix: values for these probes, or no liveness probe on the indexer/ready, which returns 503 until dependencies are up, so "a startup failure only ever means hasn't bound the port yet" is not true: frontend, worker, searcher, and the code intel workers are now restarted when/readystays 503 for 300 seconds/liveness.shevery second instead of every 10Tested in this review on the EKS test instance
m5, by upgrading frommainto this branch merged ontomain. This is the cluster check the test plan lists as not yet done:mainchart on this instance, so its new probes were not exercised/healthzand/api/health, zoekt-indexserver/debug, searcher/healthz, syntect-server/health, otel-collector//liveness.shand/ready.shboth exit 0 in the containerNot tested: jaeger, cadvisor, and node-exporter probes (not deployed on this instance), slow starts near the 300 second deadline, and a busy indexer.
Fixes #296.
Every probed container in the
sourcegraphchart now renders the same three-probe shape from one of four helpers undertemplates/_helpers/:sourcegraph.probes(/healthz+/readyonhttp-debug)sourcegraph.httpProbes(generic, path/port params)sourcegraph.postgresProbes(/liveness.sh+/ready.sh)sourcegraph.redisProbes(tcp +redis-cli ping)Shape: a startup probe (1s period,
failureThreshold=startupDeadlineSeconds) that holds liveness and readiness off until it passes; a liveness probe at 10s/5s/3 (restart after ~30s of failures); a readiness probe at 5s/5s.sourcegraph.startupDeadlineSecondsdefaults to300, overridable per service. The three Postgres databases and prometheus default to3600for crash recovery, major-version upgrades, and WAL replay.Why
#296:
repo-updater(since removed) had a 1s/3-failure liveness probe with no delay, so a resource-starved pod was killed before it could bind its port. The same pattern, softened by a flatinitialDelaySeconds, was still on every Go service: a readiness probe that fires at 0s and fails until startup finishes, and a liveness probe that is useless for the first 60–300s and then can still kill a slow start./healthzon everysourcegraph/sourcegraphbinary is a static 200 the moment the debugserver listens, so a liveness failure during startup only ever means "hasn't bound the port yet". A startup probe is the right tool for that.Behaviour changes worth a look
postgresql-16-codeinsightsimage ships the same/ready.shand/liveness.shaspostgresql-16; it now matches pgsql and codeintel-db.GET /on the S3 API port. It is asvcmainbinary like the others, so it now exposeshttp-debug: 6060and probes/healthzand/readythere./healthz), prometheus (/-/healthy), jaeger (/status), zoekt-indexserver (/debug); new liveness + readiness on grafana (/healthz,/api/health; both are root-level middleware in Grafana 7.5 so they work withserve_from_sub_path)./healthzrather than/readyz; zoekt incrementsCrasheswhile loading so the aggregator already treats results as incomplete.failureThresholdgoes from 2 to the standard 3; redis-cache from 5 to 3. Readiness still fails onLOADING, liveness still passes on an open socket, so a long RDB load keeps the pod alive but out of rotation, same as before.tcpSocketto/health./-/healthyliveness probe.pgsql-exporterandredis-exportersidecars (never had probes), and themigratorinit container.Every probe, before and after
Rendered from
helm templateonmainand on this branch withsyntacticCodeIntel,jaeger, andopenTelemetry.agentenabled. Unchanged values are plain;oldnew marks a change; + value marks a probe that did not exist before.delayisinitialDelaySeconds. Wheremainomitted a field, the Kubernetes default (delay 0 / period 10 / timeout 1 / failures 3) is shown.startupProbe
/readyonhttp-debug/healthzonhttp/liveness.sh/liveness.sh101153603600/readyonhttp-debug15120300/api/healthonhttp/debugongrpc-indexer/statusonhealth/onmetrics/on13133/on13133/liveness.sh101153603600/readyonhttp-debug/-/readyonhttpredisredis/readyonhttp-debug/readyonhttp-debug/readyonhttp-debug/healthonhttp/readyonhttp-debuglivenessProbe
/onhttp/healthzonhttp-debug600/healthzonhttp/liveness.sh/liveness.sh15015/healthzonhttp-debug50/healthzonhttp/debugongrpc-indexer/healthzongrpc/statusonhealth/onmetrics15/on1313315/on1313315/liveness.sh15015/healthzonhttp-debug600/-/healthyonhttpredis600301053redis600301023/healthzonhttp-debug/healthzonhttp-debug3000/healthzonhttp-debug600/healthonhttp50/healthzonhttp-debug600readinessProbe
/onhttp/readyonhttp-debug/ready.sh/ready.sh10515/readyonhttp-debug/api/healthonhttp/healthzongrpc/statuson13133/statusonhealth5010515/onmetrics10515/on1313310515/on1313310515/ready.sh10515/readyonhttp-debug/-/readyonhttp351203redis-cli ping10010553redis-cli ping100105/readyonhttp-debug/readyonhttp-debug/readyonhttp-debugtcp onhttp/healthonhttp10515/readyonhttp-debugChecklist
Test plan
helm unittest charts/sourcegraph: 33 suites / 204 tests pass, including the newtests/probes_test.yaml(standard shape, global deadline applied through every helper, per-service override, 1h default for databases and prometheus, codeinsights-db probes present, redis/blobstore/grafana/zoekt-indexserver specifics).helm lint charts/sourcegraphclean;./scripts/helm-docs.shregenerated the README with no stray diff.helm templatewithsyntacticCodeIntel,jaeger, andopenTelemetry.agentenabled, then dumped every container's startup/liveness/readiness probe to confirm all 21 probed containers render the expected paths, ports, and thresholds.blobstoreanswers on:6060/ready,grafanaon:3370/healthzand/api/health, andzoekt-indexserveron:6072/debug. All three were verified against source, not a running pod.