Skip to content

Fix event recorder interface migration#4896

Merged
0xavi0 merged 2 commits into
rancher:mainfrom
weyfonk:4895-fix-events-migration
Apr 13, 2026
Merged

Fix event recorder interface migration#4896
0xavi0 merged 2 commits into
rancher:mainfrom
weyfonk:4895-fix-events-migration

Conversation

@weyfonk
Copy link
Copy Markdown
Contributor

@weyfonk weyfonk commented Mar 26, 2026

The migration from controller-runtime's record.EventRecorder to events.EventRecorder seems to have changed the type of events generated, which led to permissions errors when recording events.

This commit updates Fleet's gitOps RBAC to take that new event type into account.

Refers to #4895.
Follow-up on #4678.

Additional Information

Checklist

- [ ] I have updated the documentation via a pull request in the fleet-product-docs repository.

@weyfonk weyfonk requested a review from a team as a code owner March 26, 2026 11:57
Copilot AI review requested due to automatic review settings March 26, 2026 11:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Fleet’s GitOps (gitjob) RBAC to align with the post-migration event recorder interface, which now records Kubernetes Events using the events.k8s.io API group and was previously hitting RBAC permission errors.

Changes:

  • Adjust gitjob ClusterRole permissions for Events from the core API group ("") to events.k8s.io.

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

weyfonk added 2 commits March 26, 2026 13:11
The migration from `controller-runtime`'s `record.EventRecorder` to
`events.EventRecorder` seems to have changed the type of events
generated, which led to permissions errors when recording events.

This commit updates Fleet's gitOps RBAC to take that new event type into
account.
Single-cluster end-to-end tests for GitRepo deployments now validate
that `GotNewCommit` events are generated, which should help catch future
event recording-related issues.
@weyfonk weyfonk force-pushed the 4895-fix-events-migration branch from b72b620 to cf95119 Compare March 26, 2026 12:11
Copy link
Copy Markdown
Contributor

@0xavi0 0xavi0 left a comment

Choose a reason for hiding this comment

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

LGTM

@0xavi0 0xavi0 merged commit 4d7e726 into rancher:main Apr 13, 2026
34 of 36 checks passed
0xavi0 pushed a commit to 0xavi0/fleet that referenced this pull request Apr 13, 2026
* Fix event recorder interface migration

The migration from `controller-runtime`'s `record.EventRecorder` to
`events.EventRecorder` seems to have changed the type of events
generated, which led to permissions errors when recording events.

This commit updates Fleet's gitOps RBAC to take that new event type into
account.

* Add regression end-to-end test for event generation

Single-cluster end-to-end tests for GitRepo deployments now validate
that `GotNewCommit` events are generated, which should help catch future
event recording-related issues.
0xavi0 pushed a commit to 0xavi0/fleet that referenced this pull request Apr 13, 2026
* Fix event recorder interface migration

The migration from `controller-runtime`'s `record.EventRecorder` to
`events.EventRecorder` seems to have changed the type of events
generated, which led to permissions errors when recording events.

This commit updates Fleet's gitOps RBAC to take that new event type into
account.

* Add regression end-to-end test for event generation

Single-cluster end-to-end tests for GitRepo deployments now validate
that `GotNewCommit` events are generated, which should help catch future
event recording-related issues.
0xavi0 added a commit that referenced this pull request Apr 15, 2026
* Fix event recorder interface migration (#4896)

* Fix event recorder interface migration

The migration from `controller-runtime`'s `record.EventRecorder` to
`events.EventRecorder` seems to have changed the type of events
generated, which led to permissions errors when recording events.

This commit updates Fleet's gitOps RBAC to take that new event type into
account.

* Add regression end-to-end test for event generation

Single-cluster end-to-end tests for GitRepo deployments now validate
that `GotNewCommit` events are generated, which should help catch future
event recording-related issues.

* Migrate events generation to new interface (#4678)

* Migrate events generation to new interface

With `GetEentRecorderFor` being deprecated, controllers now use the new
`GetEventRecorder` method, returning an `events.EventRecorder` instead
of a `record.EventRecorder` interface.

* Fix expectations on source component

When using the new event recorder interface, the recorder does not
populate the source component anymore; instead, the emitter can be
checked through `ReportingController`.
Besides, job creation and deletion actually happen _twice_ when
re-creating a job.

* Use formatting placeholders for errors in events

This should prevent events from containing malformed messages, if
error messages ever contain `%` symbols.

---------

Co-authored-by: Corentin Néau <tan.neau@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants