diff --git a/src/internal/packager/images/pull.go b/src/internal/packager/images/pull.go index 98737c6a06..17e6340496 100644 --- a/src/internal/packager/images/pull.go +++ b/src/internal/packager/images/pull.go @@ -332,7 +332,6 @@ func CleanupInProgressLayers(ctx context.Context, img v1.Image, cacheDirectory s } location := filepath.Join(cacheDirectory, digest.String()) info, err := os.Stat(location) - fmt.Println("location to delete is", location, err) if errors.Is(err, fs.ErrNotExist) { return nil } diff --git a/src/internal/packager/images/pull_test.go b/src/internal/packager/images/pull_test.go index 9dd65acf9d..7940fb6888 100644 --- a/src/internal/packager/images/pull_test.go +++ b/src/internal/packager/images/pull_test.go @@ -153,30 +153,28 @@ func TestPull(t *testing.T) { require.NoError(t, err) require.Empty(t, dir) }) -} - -func TestPullWithInvalidLayerInCache(t *testing.T) { - t.Parallel() - ref, err := transform.ParseImageRef("ghcr.io/fluxcd/image-automation-controller@sha256:48a89734dc82c3a2d4138554b3ad4acf93230f770b3a582f7f48be38436d031c") - require.NoError(t, err) - destDir := t.TempDir() - cacheDir := t.TempDir() - require.NoError(t, err) - layerContent := []byte("this text here is not the valid layer that the image is looking for") - invalidLayerPath := filepath.Join(cacheDir, "sha256:94c7366c1c3058fbc60a5ea04b6d13199a592a67939a043c41c051c4bfcd117a") - err = os.WriteFile(invalidLayerPath, layerContent, 0777) - require.NoError(t, err) + t.Run("pulling an image with an invalid layer in the cache should still pull the image", func(t *testing.T) { + ref, err := transform.ParseImageRef("ghcr.io/fluxcd/image-automation-controller@sha256:48a89734dc82c3a2d4138554b3ad4acf93230f770b3a582f7f48be38436d031c") + require.NoError(t, err) + destDir := t.TempDir() + cacheDir := t.TempDir() + require.NoError(t, err) + layerContent := []byte("this text here is not the valid layer that the image is looking for") + invalidLayerPath := filepath.Join(cacheDir, "sha256:94c7366c1c3058fbc60a5ea04b6d13199a592a67939a043c41c051c4bfcd117a") + err = os.WriteFile(invalidLayerPath, layerContent, 0777) + require.NoError(t, err) - pullConfig := PullConfig{ - DestinationDirectory: destDir, - CacheDirectory: cacheDir, - ImageList: []transform.Image{ - ref, - }, - } + pullConfig := PullConfig{ + DestinationDirectory: destDir, + CacheDirectory: cacheDir, + ImageList: []transform.Image{ + ref, + }, + } - _, err = Pull(context.Background(), pullConfig) - require.NoError(t, err) - require.FileExists(t, filepath.Join(destDir, "blobs/sha256/94c7366c1c3058fbc60a5ea04b6d13199a592a67939a043c41c051c4bfcd117a")) + _, err = Pull(context.Background(), pullConfig) + require.NoError(t, err) + require.FileExists(t, filepath.Join(destDir, "blobs/sha256/94c7366c1c3058fbc60a5ea04b6d13199a592a67939a043c41c051c4bfcd117a")) + }) }