Skip to content

Emit Kubernetes events from Agent controller on reconciliation #81

@fmallmann

Description

@fmallmann

Summary

The AgentReconciler currently does not emit Kubernetes events when reconciling Agent resources. Adding event recording would improve observability by surfacing reconciliation activity (e.g. agent updated, deployment created, reconcile failed) via kubectl describe agent <name> and kubectl get events.

Current State

  • RBAC markers for events and events.k8s.io are already in place (agent_reconciler.go lines 68-69)
  • The webhook layer already uses EventRecorder for recording events
  • The AgentReconciler struct has no Recorder field

Proposed Changes

  1. Add record.EventRecorder to AgentReconciler struct (internal/controller/agent_reconciler.go)
  2. Wire the recorder in cmd/main.go via mgr.GetEventRecorderFor("agent-controller")
  3. Emit events in the reconcile loop for key state transitions:
    • Normal / Updated — Agent spec reconciled successfully
    • Normal / Created — Deployment or Service created
    • Warning / ReconcileFailed — Reconciliation error
  4. Update tests to supply a fake recorder in BeforeEach blocks

Acceptance Criteria

  • kubectl describe agent <name> shows events for create/update/error
  • Existing tests pass with the recorder wired in
  • No new dependencies introduced (uses k8s.io/client-go/tools/record)

Metadata

Metadata

Labels

No labels
No labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions