fix: prevent snapshot agent Job from nesting agent deployment#200
Merged
fix: prevent snapshot agent Job from nesting agent deployment#200
Conversation
The snapshot CLI always sets AgentConfig, so `aicr snapshot` inside an agent Job tried to deploy another agent — causing UNAUTHORIZED errors due to the pod ServiceAccount lacking RBAC for Job creation. Set AICR_AGENT_MODE=true env var on agent Job containers. The CLI checks this and runs local collection instead of deploying a nested agent. Also update E2E test to invoke `aicr snapshot` from the CI runner (testing the real user workflow) instead of a manual Job.
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.
Summary
AICR_AGENT_MODE=trueenv var on agent Job containersaicr snapshotfrom CI runner (real user workflow)Root cause
The
--deploy-agentflag was removed —aicr snapshotnow always deploys an agent Job. Inside the Job container,aicr snapshotruns again and tries to deploy another agent Job, causingUNAUTHORIZEDerrors because the pod's ServiceAccount lacks RBAC for Job/Role creation.Fix
pkg/k8s/agent/job.go: AddAICR_AGENT_MODE=trueenv var to Job container specpkg/cli/snapshot.go: CheckAICR_AGENT_MODEenv var — when set, skip agent deployment and collect locallytests/e2e/run.sh: Runaicr snapshotfrom CI runner instead of manual JobTest plan
make test— all passmake lint— 0 issues