Skip to content

⚠️ Migration to the new events API#3262

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
clebs:new-events-api
Oct 14, 2025
Merged

⚠️ Migration to the new events API#3262
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
clebs:new-events-api

Conversation

@clebs
Copy link
Copy Markdown
Member

@clebs clebs commented Jul 22, 2025

This Pull Request migrates from the old events API (k8s.io/client-go/tools/record) to the new API (k8s.io/client-go/tools/events).

Closes #2141

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 22, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @clebs. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 22, 2025
@clebs
Copy link
Copy Markdown
Member Author

clebs commented Jul 22, 2025

Open Items:

  • StartRecordingToSink: manage the context/channel in the provider on ensureRecording and Stop.
  • StartWatcher: see if this is still needed and how to adapt it if it is.
  • Leader election: resourcelock.ResourceLockConfig is still using the old API.
    This has now been solved by adding an adapter that turns old API calls into new API calls (albeit pretty simplistic). So that way on the backend we have only the new API and places that require the old can use the adapter.
  • Update unit tests.

@clebs clebs changed the title ⚠ Migration to the new events API ⚠️ Migration to the new events API Jul 22, 2025
@alvaroaleman
Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2025
Copy link
Copy Markdown
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

two questions

@clebs clebs force-pushed the new-events-api branch 2 times, most recently from 6bfbd83 to 0528c33 Compare July 24, 2025 12:54
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 29, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 30, 2025
@clebs clebs marked this pull request as ready for review August 7, 2025 09:26
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 7, 2025
@sbueringer
Copy link
Copy Markdown
Member

/assign

@sbueringer
Copy link
Copy Markdown
Member

@clebs Just a heads up. If we want to get this into the next CR minor release the deadline is in 2-3 weeks. We want to release the next CR minor shortly after the Kubernetes minor which is scheduled for 27th August

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, clebs, sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [alvaroaleman,sbueringer]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sbueringer sbueringer removed the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Oct 14, 2025
@k8s-ci-robot k8s-ci-robot merged commit 2ebd17f into kubernetes-sigs:main Oct 14, 2025
10 of 11 checks passed
@clebs clebs deleted the new-events-api branch October 14, 2025 08:10
timuthy added a commit to timuthy/gardener that referenced this pull request Feb 4, 2026
timuthy added a commit to timuthy/gardener that referenced this pull request Feb 6, 2026
timuthy added a commit to timuthy/gardener that referenced this pull request Feb 6, 2026
timuthy added a commit to timuthy/gardener that referenced this pull request Feb 11, 2026
gardener-prow bot pushed a commit to gardener/gardener that referenced this pull request Feb 13, 2026
…`v0.23.1`, `sigs.k8s.io/controller-tools` to `v0.20.0` (#13982)

* `make tidy && make generate`

* Solve `OpenTelemetry-Operator` dependency issue

The `OpenTelemetry-Operator` includes dependencies to an older version of `sigs.k8s.io/controller-runtime` which is incompatible with the version (v0.23) used in Gardener.
Copying the API packages solves the dependency conflict for now.
See open-telemetry/opentelemetry-operator#4667 for more information.

* Adapt to incompatible changes

* Adapt `OpenAPI` generation

The generation needs to be adapted due to kubernetes/kube-openapi#563

* Migrate to `k8s.io/client-go/tools/events`

Motivated by kubernetes-sigs/controller-runtime#3262

* Refactor: Remove obsolete `rest.Config` constructor

* Add `ReconciliationTimeout` panel

Add `ReconciliationTimeout` panel to the controller details dashboard. The uses the newly introduced `controller_runtime_reconcile_timeouts_total metric` metric (see kubernetes-sigs/controller-runtime#3382).

* Change `NodeAgentAuthorizer` integration test

Don't use the event recorder to test patch permissions.
We've seen cases where the event recorder drops events if they are recorded too quickly.
felix-kaestner added a commit to ironcore-dev/network-operator that referenced this pull request Mar 27, 2026
Upgrades controller-runtime from v0.22.4 to v0.23.3. The k8s.io/*
packages were already at v0.35.0 and required no changes.

The priority queue is now enabled by default
(kubernetes-sigs/controller-runtime#3332), so the explicit
UsePriorityQueue: new(true) in cmd/main.go is dropped.

The webhook builder API changed to a generic form
(kubernetes-sigs/controller-runtime#3360).
NewWebhookManagedBy(mgr).For(&T{}) is replaced by
NewWebhookManagedBy(mgr, &T{}). Validators are migrated from the
deprecated CustomValidator interface with runtime.Object signatures
to the typed Validator[T] interface with concrete types, removing
the type assertion boilerplate. Test cases for wrong-object-type
errors are removed as they are no longer expressible at runtime.

The events API changed from k8s.io/client-go/tools/record to
k8s.io/client-go/tools/events (kubernetes-sigs/controller-runtime#3262).
GetEventRecorderFor is replaced by GetEventRecorder. All controllers
and the provisioning server are updated accordingly, and call sites
are updated to the new Eventf signature which adds related object
and action fields. Tests use the new events.NewFakeRecorder.
felix-kaestner added a commit to ironcore-dev/network-operator that referenced this pull request Mar 27, 2026
The priority queue is now enabled by default
(kubernetes-sigs/controller-runtime#3332), so the explicit
UsePriorityQueue: new(true) in cmd/main.go is dropped.

The webhook builder API changed to a generic form
(kubernetes-sigs/controller-runtime#3360).
NewWebhookManagedBy(mgr).For(&T{}) is replaced by
NewWebhookManagedBy(mgr, &T{}). Validators are migrated from the
deprecated CustomValidator interface with runtime.Object signatures
to the typed Validator[T] interface with concrete types, removing
the type assertion boilerplate. Test cases for wrong-object-type
errors are removed as they are no longer expressible at runtime.

The events API changed from k8s.io/client-go/tools/record to
k8s.io/client-go/tools/events (kubernetes-sigs/controller-runtime#3262).
GetEventRecorderFor is replaced by GetEventRecorder. All controllers
and the provisioning server are updated accordingly, and call sites
are updated to the new Eventf signature which adds related object
and action fields. Tests use the new events.NewFakeRecorder.
felix-kaestner added a commit to ironcore-dev/network-operator that referenced this pull request Mar 27, 2026
The priority queue is now enabled by default
(kubernetes-sigs/controller-runtime#3332), so the explicit
UsePriorityQueue: new(true) in cmd/main.go is dropped.

The webhook builder API changed to a generic form
(kubernetes-sigs/controller-runtime#3360).
NewWebhookManagedBy(mgr).For(&T{}) is replaced by
NewWebhookManagedBy(mgr, &T{}). Validators are migrated from the
deprecated CustomValidator interface with runtime.Object signatures
to the typed Validator[T] interface with concrete types, removing
the type assertion boilerplate. Test cases for wrong-object-type
errors are removed as they are no longer expressible at runtime.

The events API changed from k8s.io/client-go/tools/record to
k8s.io/client-go/tools/events (kubernetes-sigs/controller-runtime#3262).
GetEventRecorderFor is replaced by GetEventRecorder. All controllers
and the provisioning server are updated accordingly, and call sites
are updated to the new Eventf signature which adds related object
and action fields. Tests use the new events.NewFakeRecorder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to use events.EventRecorder instead of record.EventRecorder

5 participants