decorators: replace init() panics with lazy error propagation - #3910
decorators: replace init() panics with lazy error propagation#3910sebrandon1 wants to merge 1 commit into
Conversation
Convert jq query compilation from panicking in init() to lazy initialization via sync.Once with proper error returns. Failures now surface as reconciliation errors in Component.Reference() rather than crashing the operator process at startup.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @sebrandon1. Thanks for your PR. I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe decorator package now initializes component and CSV jq queries lazily and safely with Changesjq query initialization
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change replaces startup panics with lazy error propagation and adds focused coverage; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 golangci-lint (2.13.2)Error: can't load config: can't unmarshal config by viper (flags, file): 1 error(s) decoding:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I'm concerned that the failure of compiling jq queries is really a coding error, and not a run-time error. There is nothing we can do on a failure to recover. Failing in In other words, there's no way to recover, so why not fail immediately? |
|
Good point, generally I try to not use I'm good either way if you prefer the original Init() I can just close it. Thanks @tmshort! |
Summary
init()panics withsync.Oncelazy initialization for jq query compilation indecorators/operator.goComponent.Reference()instead of crashing the operator process at startupjqQueries()verifying successful compilation andsync.OnceidempotencyTest Plan
go test ./pkg/controller/operators/decorators/...— 9/9 passgo vetcleanSummary by CodeRabbit
Bug Fixes
Tests