Skip to content

Migrate off deprecated controller-runtime events API (GetEventRecorderFor) and scheme.Builder #171

Description

@viniciusdc

Summary

Recent controller-runtime releases deprecate the old events API: manager.GetEventRecorderFor (returns k8s.io/client-go/tools/record.EventRecorder) is deprecated in favor of GetEventRecorder (returns k8s.io/client-go/tools/events.EventRecorder), and apimachinery's scheme.Builder is deprecated as well.

Once the operator is on a controller-runtime version that carries these deprecations, staticcheck flags every use as SA1019.

We should migrate off both rather than sit on the deprecated APIs indefinitely.

Affected code

  • cmd/operator/main.go - the Recorder wiring for the auth, tls, and core reconcilers all call mgr.GetEventRecorderFor(...).
  • api/v1/groupversion_info.go - SchemeBuilder = &scheme.Builder{...}.
  • Every reconciler that holds a Recorder record.EventRecorder field and calls r.Recorder.Event(obj, eventtype, reason, message) (auth, tls, routing, core).

Why it is not a one-line swap

GetEventRecorder returns the new events.EventRecorder, whose surface differs from the old record.EventRecorder:

  • old: Event(object runtime.Object, eventtype, reason, message string)
  • new: Eventf(regarding, related runtime.Object, eventtype, reason, action, note string, args ...interface{})

So the migration is not just renaming the constructor - it changes the Recorder field types on every reconciler and rewrites all event-emission call sites to the new signature (including the "emit only on reason transition" pattern the reconcilers use today). scheme.Builder needs its own small follow-up per the apimachinery guidance.

Current state

The SA1019 warnings for these specific sites are excluded in .golangci.yml (scoped to cmd/operator/main.go and api/v1/groupversion_info.go) so lint stays green in the meantime. This issue tracks doing the actual migration and removing that exclusion.

Definition of done

  • Reconcilers use the new events.EventRecorder (GetEventRecorder) with call sites updated to Eventf, preserving current event semantics (reasons, transition-gating).
  • scheme.Builder usage in api/v1/groupversion_info.go migrated per the apimachinery replacement.
  • The SA1019 exclusion in .golangci.yml is removed and make lint is clean without it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Size

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions