Skip to content

Commit

Permalink
fix: use overlay whiteouts when extracting tar layers
Browse files Browse the repository at this point in the history
If a tar layer has a deleted file, a whiteout entry is created. However,
when extracting tar and overlay whiteouts are incompatible.

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
  • Loading branch information
rchincha committed Dec 12, 2023
1 parent f265e66 commit cba80a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/overlay/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func unpackOne(l ispec.Descriptor, ociDir string, extractDir string) error {
return err
}

err = layer.UnpackLayer(extractDir, uncompressed, nil)
err = layer.UnpackLayer(extractDir, uncompressed, &layer.UnpackOptions{WhiteoutMode: layer.OverlayFSWhiteout})
if err != nil {
if rmErr := os.RemoveAll(extractDir); rmErr != nil {
log.Errorf("Failed to remove dir '%s' after failed extraction: %v", extractDir, rmErr)
Expand Down
24 changes: 24 additions & 0 deletions test/publish.bats
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,27 @@ published:
EOF

}

@test "building from published images with whiteouts" {
cat > stacker.yaml <<EOF
parent:
from:
type: docker
url: docker://ghcr.io/project-stacker/alpine:edge
run: |
rm -rf /etc/apk/repositories
EOF
stacker build
stacker publish --skip-tls -d ocibuilds --url docker://${REGISTRY_URL} --tag latest
stacker clean

cat > stacker.yaml <<EOF
child:
from:
type: docker
url: docker://localhost:8080/parent:latest
run: |
[ ! -f /etc/apk/repositories ]
EOF
stacker build
}

0 comments on commit cba80a2

Please sign in to comment.