Repository navigation
fix: release OCM resource handles after fetching and localization - #1026
Merged
jakobmoellerdev merged 1 commit intoOct 17, 2026
Merged
jakobmoellerdev merged 1 commit into
jakobmoellerdev merged 1 commit into
Conversation
Close component version handles returned by resource resolution in GetResource and localization, including downstream error paths. Tie access method cleanup to resource readers and close the method if opening the reader fails. Add ownership regression tests and a local CTF reference-count test covering repeated localization lookups. Signed-off-by: Theodore Siemens-Rhodes <theodore.siemens-rhodes@sap.com>
c5426746
marked this pull request as ready for review
October 16, 2026 23:38
jakobmoellerdev
approved these changes
Oct 17, 2026
jakobmoellerdev
approved these changes
Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it
Fix missing cleanup of OCM component version handles and resource access methods during resource fetching and localization. Repeated reconciliations can retain references to component and repository state after the operation has finished.
ResolveResourceReferencereturns an owned component version handle, including a duplicated handle when the reference path is empty. BothGetResourceand the localization resolver discarded this handle. Closing the caller's original component version does not release that additional reference.This change closes the resolved handle when either operation returns, including error paths. Resource readers also retain their access method until the reader is closed, and close the method immediately if opening the reader fails. Any cleanup error on that failure path is joined with the original error.
Validation
mainand pass with this change.GOTOOLCHAIN=go1.26.8 go test ./pkg/ocm ./controllers -count=1passes.GOTOOLCHAIN=go1.26.8 make lintreports zero issues.Controller evidence
This issue was investigated in a Kubernetes deployment running
ocm-controller v0.33.0. The attached before/after charts show CPU dropping from roughly 1.5–1.7 cores to 0.7–0.8 cores. Memory grows much more slowly, remaining around 0.5–0.8 GB during the post-deployment observation window, compared with repeated climbs above 2 GB beforehand.The controller used for this comparison includes these cleanup fixes and the separate SDK finalizer-cycle fix in open-component-model/ocm#2144. The charts show their combined effect; the regression tests above isolate the controller cleanup defects. Some gradual memory growth remains visible, so these observations do not establish that every source of growth is resolved.
cc @Skarlso @dee0sap
Which issue(s) this PR is related to
Related to open-component-model/ocm-project#778 — memory leak in ocm controller 0.27.3.
Previous controller cleanup work: open-component-model/ocm-controller#799.
Related SDK fix: open-component-model/ocm#2144.