Cannot record events outside reconciliation loop or for arbitrary resources (`RegisteredController#eventRecorder` missing)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 54/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 945
- Fork
- 247
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của operator-framework/java-operator-sdk
-
Make failure handling in EventRecorder configurable (fail-on-error option)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
operator-framework/java-operator-sdk#3687 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
on-demand
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
operator-framework/java-operator-sdk#3671 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
operator-framework/java-operator-sdk#3643 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
operator-framework/java-operator-sdk#3568 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
operator-framework/java-operator-sdk#3563 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của operator-framework/java-operator-sdk
Issue tương tự
-
ImporterNoConsensus and ImporterFileVerificationErrors alerts can't fire on consensus failureĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hiero-ledger/hiero-mirror-node#14665 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
cadence-workflow/cadence#8745 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
oracle/graalvm-reachability-metadata#12168 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/frontend area/test kind/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
camunda/camunda#69073 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Patient profile returns a server error for a person with observation periods but no clinical recordsCó thể đã có người làm @DG47 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày