Reject cyclic substitutesFor chains instead of looping until OOM#2038
Conversation
A bundle whose olm.substitutesFor annotation references its own CSV name (or a set of bundles forming an indirect cycle) sent the chain walks in addSubstitutesFor into infinite loops: the skips-accumulating walk grows its slice on every iteration until the process dies with "fatal error: runtime: out of memory". This is how a single self-referencing bundle in web-terminal-operator 1.7.x metadata took down IIB catalog builds (OCPBUGS-37284). Guard every substitutesFor chain walk with a visited set seeded with the walk's starting node, so any cycle - direct or indirect - fails fast with an error naming the offending bundle instead of exhausting memory. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Harald Klein <hklein@redhat.com>
|
Hi @haklein. 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. |
|
/ok-to-test |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2038 +/- ##
==========================================
+ Coverage 58.81% 58.83% +0.01%
==========================================
Files 141 141
Lines 13434 13454 +20
==========================================
+ Hits 7901 7915 +14
- Misses 4323 4325 +2
- Partials 1210 1214 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hey @haklein thank you for your PR. IMO we should merge this PR but we should not allow further PRs against deprecated SQLite code. |
fair enough, thanks for your feedback. Will keep that in mind when picking further backlog candidates. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: grokspawn The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
f9556d7
into
operator-framework:master
No fault of yours. I just want to make sure we're careful about communicating that this is going away soon, so there will be extremely limited opportunity for anyone to make use of this fix. |
A bundle whose
olm.substitutesForannotation references its own CSV name (or a set of bundles forming an indirect cycle) causes an endless loop when walking the chain inaddSubstitutesFor. This finally leads to a OOM condition:fatal error: runtime: out of memory. (OCPBUGS-37284).Guard every
substitutesForchain walk with a visited set seeded with the walk's starting node, so any cycle - direct or indirect - fails fast with an error naming the offending bundle instead of exhausting memory.Description of the change:
Add a visited-set guard (
markSeen) to all five substitutesFor chainwalks in
pkg/sqlite/addSubstitutesFor. A cyclic chain now fails withcyclic substitutesFor chain detected involving "<name>"instead oflooping forever.
Regression tests: self-reference (
olm.substitutesFor== own CSV name)and indirect cycle (A→B→A). Both hang on master, "green" with the fix.
Motivation for the change:
OCPBUGS-37284 — a bundle whose
olm.substitutesForreferences its ownname sends the walk at
load.go:293into an infinite loop, growingskipseach iteration untilfatal error: runtime: out of memory(broke IIB builds for web-terminal-operator 1.7.x).
Same guard pattern as the existing
replacescycle checks:pkg/sqlite/load.go(replaceCycle) andalpha/model/model.go(validateReplacesChain).Reviewer Checklist
/docs