Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

🌱 Update AgentCardSyncReconciler - #175

Merged
pdettori merged 7 commits into
rossoctl:mainfrom
pdettori:issue-166
Feb 4, 2026
Merged

pdettori merged 7 commits into
rossoctl:mainfrom
pdettori:issue-166

Conversation

@pdettori

@pdettori pdettori commented Feb 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Update AgentCardSyncReconciler

Changes to agentcardsync_controller.go:

  1. Added EnableLegacyAgentCRD field to the reconciler struct to control whether Agent CRD watching is enabled
  2. Added new reconcile methods:
    - ReconcileDeployment() - handles Deployment events
    - ReconcileStatefulSet() - handles StatefulSet events
    - ReconcileAgent() - handles legacy Agent CRD events (renamed from Reconcile)
  3. Added helper methods:
    - shouldSyncWorkload() - checks if a workload has required labels
    - ensureAgentCard() - creates or updates AgentCard with targetRef
    - createAgentCardForWorkload() - creates new AgentCard with targetRef
    - hasOwnerReferenceForObject() - generic owner reference check
  4. Updated SetupWithManager() to:
    - Create separate controllers for Deployments, StatefulSets, and Agent CRDs
    - Use adapter types to route reconcile requests to the appropriate method
    - Filter resources using agentLabelPredicate() (kagenti.io/type=agent)
  5. Migration support: The ensureAgentCard() method automatically migrates existing AgentCards from selector to targetRef format

Changes to cmd/main.go:

  • Updated AgentCardSyncReconciler initialization to:
    • Always create the controller (not conditionally)
    • Pass EnableLegacyAgentCRD flag to control Agent CRD watching

Changes to agentcardsync_controller_test.go:

Added comprehensive tests for:

  • Agent CRD reconciliation (creates AgentCard with targetRef to Agent)
  • Deployment reconciliation (creates AgentCard with targetRef to Deployment)
  • StatefulSet reconciliation (creates AgentCard with targetRef to StatefulSet)
  • Migration from selector to targetRef format
  • Filtering out workloads without protocol labels

Key Features:

  1. AgentCards now use targetRef instead of selector:
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: my-agent
  1. Owner references are set on the Deployment/StatefulSet/Agent for automatic garbage collection
  2. Backward compatibility:
    - Existing AgentCards with selector are automatically migrated to targetRef
    - Legacy Agent CRD support can be disabled via --enable-legacy-agent-crd=false
  3. All tests pass (52 passed, 2 pre-existing failures in AgentBuild tests unrelated to these changes)

Related issue(s)

Fixes #166

🤖 Assisted by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the AgentCardSync controller to create/migrate AgentCards using spec.targetRef and to reconcile agent workloads (Deployments/StatefulSets) in addition to the legacy Agent CRD, gated by a new --enable-legacy-agent-crd flag.

Changes:

  • Added separate reconcile paths/controllers for Deployments, StatefulSets, and (optionally) legacy Agent CRDs.
  • Switched AgentCard creation to spec.targetRef and added selector→targetRef migration behavior.
  • Wired a new --enable-legacy-agent-crd flag through cmd/main.go and expanded controller test coverage for the new reconcile paths.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
kagenti-operator/internal/controller/agentcardsync_controller.go Adds workload reconcilers, targetRef-based AgentCard ensure/create, and optional legacy Agent CRD watching.
kagenti-operator/internal/controller/agentcardsync_controller_test.go Adds tests for Deployment/StatefulSet reconciliation and selector→targetRef migration.
kagenti-operator/internal/controller/agentcard_controller.go Adds optional legacy Agent watches and deprecation warnings for selector/legacy labels.
kagenti-operator/internal/controller/agentcard_controller_test.go Formatting-only adjustments in selector matching tests and label protocol test.
kagenti-operator/cmd/main.go Introduces --enable-legacy-agent-crd and passes it to both AgentCard and AgentCardSync controllers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cwiklik cwiklik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@pdettori
pdettori merged commit 3d3ad77 into rossoctl:main Feb 4, 2026
2 checks passed
@pdettori
pdettori deleted the issue-166 branch February 4, 2026 15:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update AgentCardSyncReconciler

3 participants