From 33b037b02dcaa1d5e652ed44248c12fb01d4b71f Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Tue, 12 Dec 2023 20:12:13 +0000 Subject: [PATCH] fix: use overlay whiteouts when extracting tar layers 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 --- pkg/overlay/pack.go | 2 +- test/publish.bats | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pkg/overlay/pack.go b/pkg/overlay/pack.go index 38109cc0..b7e14285 100644 --- a/pkg/overlay/pack.go +++ b/pkg/overlay/pack.go @@ -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) diff --git a/test/publish.bats b/test/publish.bats index 029e1a8a..8658e701 100644 --- a/test/publish.bats +++ b/test/publish.bats @@ -243,3 +243,31 @@ published: EOF } + +@test "building from published images with whiteouts" { + # This tests the case where an image is published after deleting some entries + # We expect that the published image can now be used to build another image, + # while respecting the whiteouts (due to deletion) + + cat > stacker.yaml < stacker.yaml <