Skip to content

Use events.k8s.io API group instead of legacy core/v1 Events#386

Open
databus23 wants to merge 1 commit into
masterfrom
fix/use-events-k8s-io-api
Open

Use events.k8s.io API group instead of legacy core/v1 Events#386
databus23 wants to merge 1 commit into
masterfrom
fix/use-events-k8s-io-api

Conversation

@databus23

Copy link
Copy Markdown
Member

Summary

  • Remove dead custom event.EventBroadcaster — it only affected the deprecated record.EventBroadcaster path in controller-runtime, while mgr.GetEventRecorder() uses the newer events.k8s.io API exclusively
  • Update RBAC markers from groups=core to groups=events.k8s.io for events
  • Remove stale events entry from leader election role (client-go v0.36.0 leader election uses leases only)
  • Update test assertions to use eventsv1.EventList and regarding.name field selector

Fixes production error:

events.events.k8s.io "..." is forbidden: User "system:serviceaccount:...:maintenance-controller" cannot patch resource "events" in API group "events.k8s.io"

Test plan

  • All 291 unit/integration tests pass (gmake build/cover.out)
  • Binary builds clean (gmake build-all)
  • Generated config/rbac/role.yaml correctly shows events.k8s.io group
  • Deploy to a test cluster, trigger state transition, verify kubectl describe node shows events
  • Verify no permission errors in controller logs

The custom event broadcaster (event/event.go) only affected the
deprecated record.EventBroadcaster path in controller-runtime, while
mgr.GetEventRecorder() uses the newer events.k8s.io API exclusively.
This caused RBAC errors in production since the ClusterRole only
granted access to core/v1 events.

Remove the dead custom broadcaster, update RBAC markers to
events.k8s.io, and update test assertions to use eventsv1.EventList.
@github-actions

Copy link
Copy Markdown

Merging this branch changes the coverage (2 decrease, 1 increase)

Impacted Packages Coverage Δ 🤖
github.com/sapcc/maintenance-controller 0.00% (ø)
github.com/sapcc/maintenance-controller/controllers 85.42% (ø)
github.com/sapcc/maintenance-controller/e2e 0.00% (ø)
github.com/sapcc/maintenance-controller/esx 71.89% (+0.59%) 👍
github.com/sapcc/maintenance-controller/event 0.00% (-10.84%) 💀
github.com/sapcc/maintenance-controller/kubernikus 62.11% (-3.16%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/sapcc/maintenance-controller/controllers/node_controller.go 83.05% (ø) 59 49 10
github.com/sapcc/maintenance-controller/esx/runnable.go 75.97% (+0.65%) 154 117 (+1) 37 (-1) 👍
github.com/sapcc/maintenance-controller/event/event.go 0.00% (-10.84%) 0 (-83) 0 (-9) 0 (-74) 💀
github.com/sapcc/maintenance-controller/main.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/sapcc/maintenance-controller/controllers/node_controller_test.go
  • github.com/sapcc/maintenance-controller/controllers/suite_test.go
  • github.com/sapcc/maintenance-controller/e2e/e2e_test.go
  • github.com/sapcc/maintenance-controller/kubernikus/suite_test.go

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.

2 participants