Skip to content

Conversation

@erain
Copy link

@erain erain commented Jan 13, 2026

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

  • Switch controller event emission to events.k8s.io/v1 using the client-go events broadcaster.
  • Fail fast on startup if the events.k8s.io/v1 API is not available.
  • Map action to reason consistently for v1 events.
  • Keep leader-election events on core/v1 (no forked behavior).
  • Update RBAC/Helm roles to allow events.k8s.io writes.
  • Update unit/integration tests to assert v1 event shape and series behavior.
  • Add a benchmark for v1 event recording throughput.

Which issue(s) this PR fixes:

Fixes # (n/a)

Special notes for your reviewer:

  • The new event broadcaster is wired for controllers only; leader-election remains unchanged.
  • Tests cover v1 event emission and series aggregation via events.EventRecorder.

Performance results:

# Baseline (upstream/main + local temp benchmark using core/v1 recorder)
$ go test -run=^$ -bench=BenchmarkEventRecorderCoreV1 ./pkg/controllers
BenchmarkEventRecorderCoreV1-12  578979  4312 ns/op  1347 B/op  16 allocs/op

# This PR (events.k8s.io/v1)
$ go test -run=^$ -bench=BenchmarkEventRecorderV1 ./pkg/controllers
BenchmarkEventRecorderV1-12  458974  2531 ns/op  1626 B/op  10 allocs/op

Does this PR introduce a user-facing change?

JobSet controllers now emit Kubernetes events using the `events.k8s.io/v1` API.

@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jan 13, 2026
@netlify
Copy link

netlify bot commented Jan 13, 2026

Deploy Preview for kubernetes-sigs-jobset canceled.

Name Link
🔨 Latest commit e7a27a4
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-jobset/deploys/6966cce017923000080792a2

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 13, 2026
@k8s-ci-robot
Copy link
Contributor

Welcome @erain!

It looks like this is your first PR to kubernetes-sigs/jobset 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/jobset has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: erain
Once this PR has been reviewed and has the lgtm label, please assign danielvegamyhre for approval. For more information see the Code Review Process.

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

Details Needs approval from an approver in each of these files:

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

@k8s-ci-robot
Copy link
Contributor

Hi @erain. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 13, 2026
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 13, 2026
@kannon92
Copy link
Contributor

/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 Jan 14, 2026
@GiuseppeTT
Copy link
Contributor

/retest

I'm rerunning the tests, but I suspect this is not a flake.

@kannon92
Copy link
Contributor

Trying out copilot reviews right now.

Copy link
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

This PR migrates controller event emission from the legacy core/v1 events API to the newer events.k8s.io/v1 API using client-go's events broadcaster. The migration ensures fail-fast behavior if the v1 events API is unavailable, while keeping leader-election events unchanged.

Changes:

  • Replaced record.EventRecorder with events.EventRecorder across all controllers
  • Added startup validation for events.k8s.io/v1 API availability with proper error handling
  • Updated RBAC permissions from core events to events.k8s.io group in both kustomize and Helm configurations
  • Updated integration and unit tests to assert v1 event structure (regarding, Series.Count) and use v1 fake recorders
  • Added benchmark for v1 event recording performance

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
main.go Implements newEventBroadcaster with API availability check; wires v1 event recorders to controllers
pkg/controllers/jobset_controller.go Updates event recorder type and Eventf calls to 6-parameter v1 signature; updates RBAC annotation
pkg/controllers/pod_controller.go Updates event recorder type and RBAC annotation
pkg/controllers/volume_claim_policy.go Updates Eventf call to 6-parameter v1 signature
pkg/controllers/*_test.go Replaces old event broadcaster/recorder with events.NewFakeRecorder
test/integration/controller/suite_test.go Sets up v1 event broadcaster with proper initialization and shutdown
test/integration/controller/jobset_controller_test.go Updates event assertions to use v1 fields (regarding, Series.Count)
pkg/controllers/events_benchmark_test.go Adds benchmark for v1 event recording with custom sink implementation
config/components/rbac/role.yaml Replaces core events RBAC with events.k8s.io group permissions
charts/jobset/templates/controller/cluster_role.yaml Updates Helm RBAC to use events.k8s.io API group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

4 participants