Skip to content

feat: record events about objects other than the primary resource - #3690

Open
afalhambra-hivemq wants to merge 2 commits into
operator-framework:nextfrom
afalhambra-hivemq:feat/event-recorder-other-objects-3686
Open

afalhambra-hivemq wants to merge 2 commits into
operator-framework:nextfrom
afalhambra-hivemq:feat/event-recorder-other-objects-3686

Conversation

@afalhambra-hivemq

@afalhambra-hivemq afalhambra-hivemq commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

The recorder could only record about the primary resource. A child controller can now record on its parent (or any other object) from the reconciliation:

context.eventRecorder(parent).warn("ChildFailed", "could not reconcile child " + name);

context.eventRecorder() works as before. Recording outside of a reconciliation is deliberately not part of this (see the discussion in the issue), that belongs to a standalone recorder in fabric8.

Low level API (experimental): a custom EventRecorder implements record(HasMetadata, EventRecord, Context<?>), the old record(EventRecord, Context<?>) and forContext stay as defaults, toEvent in DefaultEventRecorder takes the object too. In the 5.7 migration guide, plus a new docs page for the recorder.

Left out on purpose: the related field of events, nothing in kubectl shows it and it would need to be part of the event identity. Follow-up if someone needs it.

Fixes #3686

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 73fabbc8-4855-44fe-aae8-9604bc9ead9b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@afalhambra-hivemq
afalhambra-hivemq marked this pull request as ready for review November 11, 2026 11:49
Copilot AI balanced review requested due to automatic review settings November 11, 2026 11:49
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 11, 2026
@openshift-ci
openshift-ci Bot requested review from csviri and xstefank November 11, 2026 11:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the event-recorder changes.

No open issues 🎉

What changed in this PR

Extends Java Operator SDK’s event recorder to support arbitrary target objects and recording outside reconciliation loops, addressing #3686 while preserving context.eventRecorder() usage.

Changes:

  • Adds controller-bound recorders and a context overload for recording events about other objects.
  • Refactors the experimental recorder and sink APIs to accept explicit resources and controller configuration.
  • Adds coverage for the new entry points and documents usage, permissions, and migration steps.
File Description
operator-framework/​src/​test/​java/​io/​javaoperatorsdk/​operator/​baseapi/​eventrecorder/​EventRecorderReconciler.java Records events about a separate ConfigMap for integration coverage.
operator-framework/​src/​test/​java/​io/​javaoperatorsdk/​operator/​baseapi/​eventrecorder/​EventRecorderIT.java Tests other-object and outside-reconciliation recording.
operator-framework-core/​src/​test/​java/​io/​javaoperatorsdk/​operator/​processing/​ControllerTest.java Verifies controller-bound delegation and default recording behavior.
operator-framework-core/​src/​test/​java/​io/​javaoperatorsdk/​operator/​api/​reconciler/​DefaultContextTest.java Tests primary-resource and explicit-object binding.
operator-framework-core/​src/​test/​java/​io/​javaoperatorsdk/​operator/​api/​event/​EventRecorderTest.java Tests default bound views and argument validation.
operator-framework-core/​src/​test/​java/​io/​javaoperatorsdk/​operator/​api/​event/​EventRecorderRegressionTest.java Migrates regression tests to the explicit-resource API.
operator-framework-core/​src/​test/​java/​io/​javaoperatorsdk/​operator/​api/​event/​DefaultEventRecorderTest.java Covers arbitrary targets, binding, and event identity.
operator-framework-core/​src/​test/​java/​io/​javaoperatorsdk/​operator/​api/​event/​DefaultEventRecorderIntegrationTest.java Updates API-server tests for the revised signatures.
operator-framework-core/​src/​test/​java/​io/​javaoperatorsdk/​operator/​api/​config/​ConfigurationServiceOverriderTest.java Adapts the custom recorder fixture to the functional interface.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​RegisteredController.java Exposes a controller-bound event recorder.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​processing/​Controller.java Binds the configured recorder to the controller.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​reconciler/​DefaultContext.java Delegates recording through resource-bound views.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​reconciler/​Context.java Adds an event recorder overload for arbitrary objects.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​ResourceEventRecorder.java Clarifies object and controller binding in Javadoc.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​EventSink.java Replaces reconciliation context with controller configuration.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​EventRecorder.java Adds explicit-target recording and default binding methods.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​DefaultEventSink.java Adopts the updated sink signature.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​DefaultEventRecorder.java Assembles events from explicit objects and controller configuration.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​ControllerEventRecorder.java Defines the controller-bound recording API.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​BoundResourceEventRecorder.java Implements object-and-controller-bound delegation.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​event/​BoundControllerEventRecorder.java Implements controller-bound delegation and resource views.
operator-framework-core/​src/​main/​java/​io/​javaoperatorsdk/​operator/​api/​config/​ConfigurationService.java Updates Javadoc for shared recorder inputs.
docs/​content/​en/​docs/​migration/​v5-7-migration.md Documents experimental API changes and migration steps.
docs/​content/​en/​docs/​documentation/​operations/​configuration.md Links event configuration to the new guide.
docs/​content/​en/​docs/​documentation/​kubernetes-events.md Explains recording, aggregation, customization, failures, and permissions.
docs/​content/​en/​docs/​documentation/​_index.md Adds the event-recording guide to the documentation index.

Review effort: Balanced

@csviri

csviri commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

see my comment here: #3686 (comment)

@afalhambra-hivemq

Copy link
Copy Markdown
Contributor Author

Narrowing the scope of this PR as agreed in the issue

@csviri csviri changed the title feat: record events about any object and outside reconciliations feat: record events about any object Nov 16, 2026
Signed-off-by: Antonio Fernandez Alhambra <antonio.alhambra@hivemq.com>
Signed-off-by: Antonio Fernandez Alhambra <antonio.alhambra@hivemq.com>
@afalhambra-hivemq
afalhambra-hivemq force-pushed the feat/event-recorder-other-objects-3686 branch from 46d0b21 to 73c4ca1 Compare November 16, 2026 16:07
@afalhambra-hivemq afalhambra-hivemq changed the title feat: record events about any object feat: record events about objects other than the primary resource Nov 16, 2026
@afalhambra-hivemq

Copy link
Copy Markdown
Contributor Author

@csviri done, narrowed the PR to context.eventRecorder(regarding) only, the RegisteredController part is gone and Context stays in the interface. Ready for another look.

This branch has not been deployed

No deployments
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.

Cannot record events outside reconciliation loop or for arbitrary resources (RegisteredController#eventRecorder missing)

3 participants