Skip to content

fix: prevent snapshot agent Job from nesting agent deployment#200

Merged
mchmarny merged 1 commit intomainfrom
fix/snapshot-agent-nesting
Feb 24, 2026
Merged

fix: prevent snapshot agent Job from nesting agent deployment#200
mchmarny merged 1 commit intomainfrom
fix/snapshot-agent-nesting

Conversation

@mchmarny
Copy link
Copy Markdown
Member

Summary

  • Set AICR_AGENT_MODE=true env var on agent Job containers
  • CLI checks this env var and runs local collection instead of deploying a nested agent
  • Update E2E test to invoke aicr snapshot from CI runner (real user workflow)

Root cause

The --deploy-agent flag was removed — aicr snapshot now always deploys an agent Job. Inside the Job container, aicr snapshot runs again and tries to deploy another agent Job, causing UNAUTHORIZED errors because the pod's ServiceAccount lacks RBAC for Job/Role creation.

Fix

  • pkg/k8s/agent/job.go: Add AICR_AGENT_MODE=true env var to Job container spec
  • pkg/cli/snapshot.go: Check AICR_AGENT_MODE env var — when set, skip agent deployment and collect locally
  • tests/e2e/run.sh: Run aicr snapshot from CI runner instead of manual Job

Test plan

  • make test — all pass
  • make lint — 0 issues
  • E2E running locally (background)
  • CI E2E should now complete snapshot test

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.
@mchmarny mchmarny requested a review from a team as a code owner February 24, 2026 03:03
@mchmarny mchmarny self-assigned this Feb 24, 2026
@mchmarny mchmarny added the bug Something isn't working label Feb 24, 2026
@mchmarny mchmarny merged commit 399a2dc into main Feb 24, 2026
16 checks passed
@mchmarny mchmarny deleted the fix/snapshot-agent-nesting branch February 24, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant