Skip to content

feat(executor): support toleration in yaml - #902

Merged
marcleblanc2 merged 7 commits into
sourcegraph:mainfrom
jojosenthusiast:fix-executor-tolerations-json
Nov 26, 2026
Merged

marcleblanc2 merged 7 commits into
sourcegraph:mainfrom
jojosenthusiast:fix-executor-tolerations-json

Conversation

@jojosenthusiast

@jojosenthusiast jojosenthusiast commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #349

Reproduction

When executor.kubernetesJob.node.tolerations is provided as a YAML list, the executor ConfigMap rendered it as a Go-style map[...] string instead of JSON. The executor then fails to parse EXECUTOR_KUBERNETES_NODE_TOLERATIONS.

Fix summary

  • Render non-string tolerations values with toJson | quote.
  • Preserve existing string/default behavior for pre-encoded JSON strings and the default empty string.
  • Add helm-unittest coverage for YAML list, pre-encoded JSON string, and default empty string inputs.
  • Add the executor k8s chart unittest suite to the existing Buildkite unittest script.

Tests run

  • git diff --check upstream/main...HEAD → pass
  • sh -n scripts/ci/helm-unittest.sh → pass
  • helm unittest -q charts/sourcegraph-executor/k8s → pass, 10/10 tests
  • helm lint charts/sourcegraph-executor/k8s → pass, 1 chart linted, 0 failed (existing metadata-name warnings only)
  • Static CI wiring check: .buildkite/pipeline.yaml runs scripts/ci/helm-unittest.sh, and the script now runs helm unittest -q charts/sourcegraph-executor/k8s

Risk

Low. Defaults remain unchanged and string inputs are preserved; YAML list/map inputs now render as JSON for the executor.

Non-goals

  • No changes to executor chart defaults.
  • No changes to sibling executor config fields with similar rendering patterns.

@marcleblanc2
marcleblanc2 requested a review from a team October 20, 2026 01:46
marcleblanc2 and others added 4 commits October 19, 2026 19:54
Apply the tolerations fix to the four sibling fields with the same bug
(requiredAffinityMatchExpressions, requiredAffinityMatchFields,
pod.affinity, pod.antiAffinity) through a shared executor.jsonValue
helper.

Strings are rendered exactly as before so the pre-escaped JSON form
documented in values.yaml keeps working; the previous commit's | quote
double-escaped those backslashes and broke existing deployments.

Document the YAML list form, add a CHANGELOG entry, and drop the CI
script change in favour of the pending all-charts unittest branch.

Amp-Thread-ID: https://ampcode.com/threads/T-01a156fd-e08b-76fb-9aef-4a705912beac
Co-authored-by: Amp <amp@ampcode.com>
…ons-json

# Conflicts:
#	charts/sourcegraph-executor/CHANGELOG.md
@shanurwan

Copy link
Copy Markdown

I tested this against the executor itself, in case it helps review. k3s v1.35.8, Helm v3.19.0, executor-kubernetes:8.1.4873 (the digest pinned in values.yaml), with an unreachable frontend URL, so a valid config passes validation and then retries connecting to the frontend.

tolerations main this PR
Documented pre-escaped string Running Running, ConfigMap identical
YAML list CrashLoopBackOff: invalid character 'm' Running, valid JSON
Default Running Running

I also decoded each rendered value into the corev1 types the executor declares (Toleration, NodeSelectorRequirement, PodAffinityTerm): all five fields pass. The branch merges cleanly onto current main, and helm unittest passes.

@marcleblanc2

Copy link
Copy Markdown
Contributor

I opened branch marc/fix-executor-tolerations-json to run Buildkite, 3334 passed.

@michaellzc michaellzc changed the title fix(executor): render tolerations as json feat(executor): support toleration in yaml Nov 26, 2026
@marcleblanc2
marcleblanc2 merged commit f689d28 into sourcegraph:main Nov 26, 2026
6 checks passed
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.

Executor Helm Chart - kubernetesJob.node.tolerations doesn't render as expected

4 participants