Cannot record events outside reconciliation loop or for arbitrary resources (`RegisteredController#eventRecorder` missing)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 54/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
調査の方向性
Read the v5.6 event recorder release notes and trace the API changes described for PRs #3570 and #3581, then inspect RegisteredController, Context, and DefaultEventRecorder. Confirm how recording is currently scoped to the primary resource and where an unbound recorder or explicit target resource could fit; done means events can be recorded outside reconciliation and targeted at a parent resource from a sub-resource controller.
索引モデルが issue の本文から書いたものです。
説明
Bug Report
What did you do?
We attempted to record a Kubernetes event for our primary/main resource from within the reconciliation loop of a sub-resource / secondary controller, following the v5.6 release notes:
https://javaoperatorsdk.io/blog/2026/09/02/version-5.6-released/#kubernetes-event-recorder
According to the release documentation:
"Outside of the reconciliation loop — from a status listener or a background task, or about an object other than the primary — use the unbound form from
RegisteredController#eventRecorder(), which is scoped to the controller rather than to a reconciliation:EventRecorder recorder = registeredController.eventRecorder(); recorder.record(someOtherResource, EventRecord.normal("Noticed", "something happened"));
What did you expect to see?
RegisteredControllerexposes aneventRecorder()method (or equivalent API) to obtain an unboundEventRecorder.EventRecorderprovides a way to record events for an arbitrary target resource (e.g.recorder.record(someOtherResource, EventRecord.normal(...))), allowing a controller reconciling a sub-resource to emit an event on its main/parent resource.
What did you see instead? Under which circumstances?
RegisteredControllerdoes not containeventRecorder(). CallingregisteredController.eventRecorder()fails to compile.- In
Context<P>,eventRecorder()returns aResourceEventRecorderstrictly bound tocontext.getPrimaryResource(). - In
DefaultEventRecorder,toEvent(...)hardcodes the target resource tocontext.getPrimaryResource():var regarding = context.getPrimaryResource(); and EventRecorder#record only accepts (EventRecord event, Context<?> context).
As a result, when reconciling a sub-resource (where context.getPrimaryResource() is the sub-resource), there is no supported way to publish an event targeting the main/parent resource.
Environment
Kubernetes cluster type: any
java-operator-sdk version: 5.6.3
java -version: 17 / 21
kubectl version: 1.30+
Possible Solution
Tracing through the PR history:
- PR #3570 (feat: Add Event Recorder) originally introduced RegisteredController#eventRecorder() and supported recording events for arbitrary objects.
- PR #3581 (refactor: configurable event recorder) refactored the API to be stateless and removed RegisteredController#eventRecorder(), inadvertently dropping the ability to record events outside a reconciliation context or targeting a resource other than context.getPrimaryResource().
Suggested fixes:
- Re-introduce an unbound EventRecorder accessible via RegisteredController, ConfigurationService, or Operator.
- Allow passing an explicit target HasMetadata targetResource (or via EventRecord / EventRecorder#record(targetResource, ...)), rather than exclusively binding to context.getPrimaryResource().
Additional context
Our use case: We have separate controllers reconciling sub-resources. When state changes or failures occur during the reconciliation of a sub-resource, we need to publish a Kubernetes event targeting the main/parent resource so users inspecting the parent resource (kubectl describe ) have visibility into events triggered by its sub-resources.
- 主要言語
- Java
- スター
- 945
- フォーク
- 247
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
operator-framework/java-operator-sdk のほかの issue
-
Make failure handling in EventRecorder configurable (fail-on-error option)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
operator-framework/java-operator-sdk#3687 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
on-demand
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
operator-framework/java-operator-sdk#3671 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
operator-framework/java-operator-sdk#3643 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
operator-framework/java-operator-sdk#3568 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
operator-framework/java-operator-sdk#3563 ·
メンテナーはふだん 1 日以内に返信
operator-framework/java-operator-sdk の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
hiero-ledger/hiero-mirror-node#14665 ·
メンテナーはふだん 1 日以内に返信
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
cadence-workflow/cadence#8745 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
oracle/graalvm-reachability-metadata#12168 ·
メンテナーはふだん 1 日以内に返信
-
area/frontend area/test kind/tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
camunda/camunda#69073 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Patient profile returns a server error for a person with observation periods but no clinical records対応中かも @DG47 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信