Skip to content

Migrate quota event emission to the supported events API #119

@scotwells

Description

@scotwells

Why it matters

Operators rely on Kubernetes Events on Instance objects to understand why a workload failed to schedule when project quota is exhausted or unavailable. That quota-failure observability was added in #118 and is now part of how operators self-diagnose.

The event emission is currently wired through controller-runtime's deprecated GetEventRecorderFor(...) / record.EventRecorder API. That API is slated for removal in a future controller-runtime release. Staying on it is a latent break risk: a routine dependency bump could break event emission or the build outright, silently degrading the quota observability operators depend on. It also leaves a //nolint:staticcheck suppression in the tree.

Migrating to the supported events API keeps the platform on maintained interfaces so quota-failure visibility keeps working through dependency upgrades, and removes the lint suppression.

Background

To keep #118 scoped, the full migration was deferred and a documented //nolint:staticcheck was placed on the recorder wiring in internal/controller/instance_controller.go (~line 963 in the merged form):

//nolint:staticcheck // GetEventRecorder (new events API) has an incompatible Eventf
// signature; migrating is out of scope here and would touch all emit sites.
// GetEventRecorderFor remains correct; migration is deferred.
r.recorder = mgr.GetLocalManager().GetEventRecorderFor("instance-controller")

Scope / what's needed

  • Switch mgr.GetLocalManager().GetEventRecorderFor("instance-controller")mgr.GetLocalManager().GetEventRecorder(), which returns an events.EventRecorder from k8s.io/client-go/tools/events.
  • Change the InstanceReconciler.recorder struct field type from record.EventRecorder to events.EventRecorder.
  • Migrate every r.recorder.Event(obj, eventtype, reason, message) emit site (multiple sites for the various quota-failure conditions) to the new signature:
    Eventf(regarding runtime.Object, related runtime.Object, eventtype, reason, action, note string, args ...any).
  • Replace record.FakeRecorder / record.NewFakeRecorder(...) in the controller tests with the events-API fake.
  • Remove the //nolint:staticcheck suppression.

Acceptance criteria

Origin

Deferred from #118.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgoPull requests that update go code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions