Skip to content

Commit c8d7eb9

Browse files
committed
feat: add Sandbox support to AgentCard controller
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>
1 parent 93a8924 commit c8d7eb9

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

kagenti-operator/internal/controller/agentcard_controller.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ type AgentCardReconciler struct {
140140
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;update;patch
141141
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;update;patch
142142
// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch
143+
// +kubebuilder:rbac:groups=agents.x-k8s.io,resources=sandboxes,verbs=get;list;watch
143144

144145
func (r *AgentCardReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
145146
agentCardLogger.V(1).Info("Reconciling AgentCard", "namespacedName", req.NamespacedName)
@@ -1282,6 +1283,16 @@ func (r *AgentCardReconciler) SetupWithManager(mgr ctrl.Manager) error {
12821283
builder.WithPredicates(workloadPredicates),
12831284
)
12841285

1286+
if SandboxCRDExists(mgr.GetConfig()) {
1287+
sandboxObj := &unstructured.Unstructured{}
1288+
sandboxObj.SetGroupVersionKind(sandboxGVK)
1289+
controllerBuilder = controllerBuilder.Watches(
1290+
sandboxObj,
1291+
handler.EnqueueRequestsFromMapFunc(r.mapWorkloadToAgentCard("agents.x-k8s.io/v1alpha1", "Sandbox")),
1292+
builder.WithPredicates(workloadPredicates),
1293+
)
1294+
}
1295+
12851296
return controllerBuilder.
12861297
Named("AgentCard").
12871298
Complete(r)

0 commit comments

Comments
 (0)