Skip to content

Unset BUILDKITE_PLUGINS when only the Kubernetes plugin was set - #4528

Open
pujitha24 wants to merge 1 commit into
buildkite:mainfrom
pujitha24:auto/issue-4525
Open

pujitha24 wants to merge 1 commit into
buildkite:mainfrom
pujitha24:auto/issue-4525

Conversation

@pujitha24

Copy link
Copy Markdown

Description

In Kubernetes mode the agent strips the kubernetes plugin from BUILDKITE_PLUGINS. When that was the step's only plugin, removeKubernetesPlugin returned [] (from json.Marshal), so the caller's == "" check never deleted the variable and BUILDKITE_PLUGINS was set to []. The job executor treats any non-empty value as "has plugins", so an agent with plugins disabled (no-plugins, or no-local-hooks/no-command-eval which imply it) failed the job before its command ran. removeKubernetesPlugin now returns nil when no plugins remain, so the existing delete branch runs.

Context

Fixes #4525

Changes

  • agent/job_runner.go: return nil, nil from removeKubernetesPlugin when the filtered list is empty; add a doc comment.
  • agent/job_runner_test.go: add TestRemoveKubernetesPlugin (only k8s plugin, k8s plus another, no k8s plugin).

Public documentation

Status: not needed

Testing

  • Tests have run locally (with go test ./...). I ran go test ./agent (passes), not the whole repo, and golangci-lint run ./agent/... (0 issues). The new test fails without the fix ("[]" vs "") and passes with it. I did not run an end-to-end agent-stack-k8s job.
  • Code is formatted (with go tool gofumpt -extra -w .)

Affiliation (optional, external contributors)

Disclosures / Credits

Written with Claude Code (AI assistant), working from the cause and suggested fix described in the issue. I did not run a live agent-stack-k8s job.

Fixes #4525

Motivation: in Kubernetes mode the agent removes the kubernetes plugin
from BUILDKITE_PLUGINS. If it was the only plugin, removeKubernetesPlugin
returned "[]", so the caller's empty-string check did not delete the
variable. The job executor counts any non-empty BUILDKITE_PLUGINS as
plugins, so on an agent with plugins disabled (no-plugins, or
no-local-hooks / no-command-eval, which imply it) the job failed before
its command ran.

Approach: return nil from removeKubernetesPlugin when no plugins remain,
so the existing delete branch in the caller runs.

Validation: added TestRemoveKubernetesPlugin. Without the fix its
"only kubernetes plugin" case fails (got "[]", want ""); with the fix it
passes. Also ran `go test ./agent` (pass) and `golangci-lint run
./agent/...` (0 issues). I did not run a live agent-stack-k8s job.

Report: buildkite#4525
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5-5 (via Claude Code)
@pujitha24
pujitha24 requested review from a team as code owners October 16, 2026 07:56
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.

Kubernetes plugin filter leaves BUILDKITE_PLUGINS=[], so agent-stack-k8s jobs fail when plugins are disabled

1 participant