This repository has been archived by the owner on Jun 4, 2021. It is now read-only.
Properly handle opaque whiteout entries in layer flattener #110
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 PR fixes a bug in the flattener's handling of layers with opaque whiteout entries (
.wh..wh..opq
files). This bug could lead to deleted files re-appearing in flattened output.Bug symptoms
According to the OCI spec on whiteouts:
The existing flattening logic does not take these files into account, leading to weird anomalies when flattening images where directories are deleted in lower layers and re-created in higher layers. As an example, imagine that I have a Dockerfile which looks something like this:
Per the spec, these filesystem changes can be represented via the following tar layers:
and
The expected flattened layer output is
The current flattening implementation does not respect the
.wh..wh..opq
file, so the flattened output incorrectly contains both the old and new files:Handling of opaque whiteout files seems to be a problem for other projects, too; see sylabs/singularity#1962 and moby/moby#34300, for example.
Solution
This PR addresses this problem by modifying the client v2.2's flattening function to properly account for opaque whiteout files. The flattener now tracks the set of directories in higher layers which have opaque whiteouts.
Testing
I added a new unit test suite
client_v2_2
and wrote tests for theextract()
flattening function.