Skip to content

fix(mutate): close layer readers immediately after extracting layer#2190

Open
caxu-rh wants to merge 2 commits into
google:mainfrom
caxu-rh:extract-defer-loop
Open

fix(mutate): close layer readers immediately after extracting layer#2190
caxu-rh wants to merge 2 commits into
google:mainfrom
caxu-rh:extract-defer-loop

Conversation

@caxu-rh

@caxu-rh caxu-rh commented Jan 12, 2026

Copy link
Copy Markdown

In mutate.extract, the closing of layerReader resources is deferred from inside a for loop. As a result, the layerReaders are left open until all layers are processed, which may accumulate on images with many layers.

Intorduce an inner function/closure to contain the layerReader and operations that use it, so that it can be released immediately after the current layer has been processed.

@google-cla

google-cla Bot commented Jan 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@caxu-rh

caxu-rh commented Jan 14, 2026

Copy link
Copy Markdown
Author

Sorry for the delay - resolved the CLA coverage. The diff looks kind of confusing, but this is essentially nesting the loop body into an anonymous function.

@codecov-commenter

codecov-commenter commented Feb 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.37838% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.93%. Comparing base (8b3c303) to head (a122583).
⚠️ Report is 146 commits behind head on main.

Files with missing lines Patch % Lines
pkg/v1/mutate/mutate.go 78.37% 4 Missing and 4 partials ⚠️

❗ There is a different number of reports uploaded between BASE (8b3c303) and HEAD (a122583). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (8b3c303) HEAD (a122583)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2190       +/-   ##
===========================================
- Coverage   71.67%   52.93%   -18.75%     
===========================================
  Files         123      165       +42     
  Lines        9935    11211     +1276     
===========================================
- Hits         7121     5934     -1187     
- Misses       2115     4562     +2447     
- Partials      699      715       +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

In mutate.extract, the closing of layerReader resources is deferred
from inside a `for` loop. As a result, the layerReaders are left open
until all layers are processed, which may accumulate on images with
many layers.

Intorduce an inner function/closure to contain the layerReader and
operations that use it, so that it can be released immediately after
the current layer has been processed.

Signed-off-by: Caleb Xu <caxu@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants