Rework layer handling to return a ResourceCloser #1743
Merged
+295
−357
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.
This is commit 4/6 in a chain. Recommended to review in order. If reviewing a later PR in the chain, you can view individual commits to see just what that PR changes.
Currently, the layers package relies on the caller of Mount*COWLayers to
subsequently call NewImageLayers, which constructs a special ImageLayers
object that can be used to later clean up the layer mounts. However,
this requires the caller to know too much about the internals of the
layer mounting process.
A cleaner approach, which I take here, is to instead return a standard
ResourceCloser from Mount*COWLayers which then knows how to clean up
whatever mounts were done. I have also changed the layers code to use
ResourceCloser in more places internally.
There is a new check in resources_*cow.go, such that the layers closer
is only stored if the container is not a hypervisor-isolated sandbox
container. This duplicates the logic that was previously in
(*ImageLayers).Release.