Repository navigation
fix: merge configured pod securityContext in agent mode (ENG-809) - #347
Merged
Merged
Conversation
Agent mode replaced the pod securityContext from the pod config with a hard-coded runAsUser 0 / fsGroup 0, silently dropping any configured values. Start from the configured securityContext and default RunAsUser and FSGroup to 0 only when they are unset.
archf
approved these changes
Nov 19, 2026
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.
Resolves ENG-809.
Problem
In agent mode,
getPodObjectreplaced the podsecurityContextfrom--configwith a hard-codedrunAsUser: 0, fsGroup: 0, so anything the pod config set there was silently dropped. On prod-sandbox this left the projected EKS Pod Identity token readable only by root, and CodingAgentV3 jobs (which drop tonode) failed Bedrock auth withEACCES.Change
podConfig.SecurityContextand setsRunAsUserandFSGroupto0only when they are unset. Docker-in-Docker still runs as root by default.0/0as before) and no change in non-agent mode.Tests
TestGetPodObject_AgentModeSecurityContextMergeinsrc/pkg/k8s_test.go:runAsUser 0,fsGroup 0(unchanged)fsGroup: 1000onlyrunAsUser 0,fsGroup 1000fsGroup: 1000Each case also checks that the pod config was not mutated.
go test ./...andgo vet ./...pass locally.Kind verification (ticket's open question)
Result: it works. With
fsGroup: 1000, uid 1000 can read the projected service-account token.Setup: kind v1.35.0 (
kind-opslevel-runner). The pod was shaped like agent-mode output: podsecurityContext {runAsUser: 0, fsGroup: <N>}, a privileged container, and a projectedserviceAccountTokenvolume (audiencepods.eks.amazonaws.com) mounted at/var/run/secrets/pods.eks.amazonaws.com/serviceaccount. Anodeuser (uid/gid 1000) was added in the container.ls -lntokensetpriv --reuid=1000 --regid=1000 --init-groups cat <token>fsGroup: 1000-rw-r----- 0 1000fsGroup: 0(today's behaviour)-rw-r----- 0 0Permission deniedThe kubelet wrote the token as
0640with group set to the fsGroup, not0600owned by the runAsUser, so the 0600 concern in the ticket doesn't apply whenrunAsUseris 0 andfsGroupis set.Caveats: this ran on kind, not EKS. On EKS the Pod Identity webhook injects the volume, but the kubelet sets file ownership the same way. The read relies on uid 1000 being in group 1000; in the
nodeimage that's its primary group.Follow-ups (out of scope)
fsGroup: 1000in the prod-sandbox pod config (opslevel-kubernetes) after a runner release.🤖 Generated with Claude Code