feat: add Sandbox support to AgentCard controller - #344
Conversation
The AgentCard controller watches Deployment and StatefulSet to trigger reconciliation when workloads change. It did not watch Sandbox, so AgentCard status wouldn't react to Sandbox lifecycle events. Add conditional Watches for Sandbox via SandboxCRDExists guard, using the existing mapWorkloadToAgentCard handler. Fixes: #340 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: cwiklik <cwiklikj@gmail.com>
mrsabath
left a comment
There was a problem hiding this comment.
Focused 10-line addition that mirrors the Sandbox watch pattern already shipping in clientregistration_controller.go (#338) and agentruntime_controller.go. Correctly uses EnqueueRequestsFromMapFunc (many-to-one via label mapping) rather than EnqueueRequestForObject (which is right for ClientRegistration but not here). All referenced helpers — SandboxCRDExists, sandboxGVK, mapWorkloadToAgentCard, workloadPredicates — already exist upstream. CRD-existence guard keeps this safe when Sandbox CRD is not installed.
Areas reviewed: Go controller code, RBAC markers, pattern parity with sibling controllers, linked issue #340.
Commits: 1, signed-off ✓
CI status: All 16 checks passing (including E2E, integration, unit, lint).
| sandboxObj, | ||
| handler.EnqueueRequestsFromMapFunc(r.mapWorkloadToAgentCard("agents.x-k8s.io/v1alpha1", "Sandbox")), | ||
| builder.WithPredicates(workloadPredicates), | ||
| ) |
There was a problem hiding this comment.
suggestion: No unit test asserts the Sandbox watch is registered when the CRD exists. This mirrors an already-tested pattern in clientregistration_controller.go (#338) and agentruntime_controller.go, so behavior is low-risk, but a small table-driven test in agentcard_controller_test.go verifying (a) watch is skipped when SandboxCRDExists returns false, and (b) a Sandbox label update triggers AgentCard reconcile, would close the loop. Could be a follow-up PR if you'd rather keep this one minimal.
Verify mapWorkloadToAgentCards correctly maps Sandbox objects with agent labels to AgentCard reconcile requests. Also verify Sandbox objects without agent labels are filtered out. Addresses review feedback on PR #344. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: cwiklik <cwiklikj@gmail.com>
|
Addressed in 2910322 — added two test cases in
Re: |
Summary
SetupWithManagerwithSandboxCRDExists()guardmapWorkloadToAgentCard("agents.x-k8s.io/v1alpha1", "Sandbox")to enqueue AgentCard reconciliation on Sandbox changesagents.x-k8s.iosandboxesThis ensures that changes to Sandbox workloads (label updates, scaling, etc.) trigger reconciliation of the associated AgentCard's status fields.
Closes #340
Test plan
kagenti.io/type: agentthat has an AgentCard → verify AgentCard status is refreshedAssisted-By: Claude Code