* Restore succeeds (skipping over the layer) if layer contents are corrupted
Signed-off-by: Natalie Arellano <narellano@vmware.com>
* Exporter does not re-use layer from volume cache if layer contents are corrupted
Signed-off-by: Natalie Arellano <narellano@vmware.com>
* Fixes
Signed-off-by: Natalie Arellano <narellano@vmware.com>
---------
Signed-off-by: Natalie Arellano <narellano@vmware.com>
* add failing test to restorer
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* restorer and exporter working as expected
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* lint
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update phase/restorer.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update phase/cache.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update cache/image_cache.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update cache/volume_cache.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update cache/volume_cache.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update cache/volume_cache.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update cache/volume_cache.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* Update cache/volume_cache.go
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* update based on feedback
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
* fix log
* temp fix
* this does not work as is. I think we need to modify img utils.
Image utils should fail with a Layer Not found in both ReuseLayer & GetLayer.
For GetLayer, when there is a missing blob, it's return an unexpected EOF error.
For ReuseLayer, when there is a missing blob, it's not returning an error but it should.
* add eof check
* add not exist check
* reuse layer test
* fix test regression
---------
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
Co-authored-by: Joey Brown <brown.joseph@salesforce.com>
* Remove deleteOrigImage function from the cache and relative test
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Revert "Remove deleteOrigImage function from the cache and relative test"
This reverts commit 17e646fc39602777a37977dd9416e59aa62f6d04.
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Implemented a new component called cache deleter which takes care of the deletion of the cache images
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Adjusted the name of the struct field
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Move the imade deleter instatiation up to the main
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Add parameter to enable/diable the deletion functionality, for now always set has enabled
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Add feature guard based on the platformAPI version
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Fixing some test titles
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Introduce ImageComparer component
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Add async go-subroutine to the delete call to speed up the process
```go
func Benchmark(b *testing.B) {
mockController := gomock.NewController(b)
fakeImageComparer := cacheMock.NewMockImageComparer(mockController)
testLogger := cmd.DefaultLogger
imageDeleter := NewImageDeleter(fakeImageComparer, testLogger, true)
for i := 0; i < b.N; i++ {
fakeOrigImage := fakes.NewImage("fake-image", "", local.IDIdentifier{ImageID: "fakeImage"})
fakeNewImage := fakes.NewImage("fake-image", "", local.IDIdentifier{ImageID: "fakeNewImage"})
fakeImageComparer.EXPECT().ImagesEq(fakeOrigImage, fakeNewImage).AnyTimes().Return(false, nil)
imageDeleter.DeleteOrigImageIfDifferentFromNewImage(fakeOrigImage, fakeNewImage)
}
}
```
The code above produced this result:
* without the go-subroutine
```
goos: darwin
goarch: amd64
pkg: github.com/buildpacks/lifecycle/cache
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Benchmark
Benchmark-12 3501 8995839 ns/op
PASS
```
* with the go-subroutine
```
goos: darwin
goarch: amd64
pkg: github.com/buildpacks/lifecycle/cache
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Benchmark
Benchmark-12 3560 9133704 ns/op
PASS
```
Speed increased by 1.53% ns/op
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
---------
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
* Validate the cache image and previous image in the analyze phase
Signed-off-by: Matthew Robertson <mattrobertson@google.com>
* Fix unit tests
Signed-off-by: Matthew Robertson <mattrobertson@google.com>
* Upgrade imgutil
Signed-off-by: Matthew Robertson <mattrobertson@google.com>
* allow-nondistributable-artifacts for windows images
Signed-off-by: Matthew Robertson <mattrobertson@google.com>
* Update docs
Signed-off-by: Matthew Robertson <mattrobertson@google.com>
---------
Signed-off-by: Matthew Robertson <mattrobertson@google.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Initialized the cache image to add an empty layer in case is needed
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
# This is the commit message #2:
Fixing compilation error caused by imgutil PR #141
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
* WIP - Initialized the cache image to add an empty layer in case is needed
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
* Pointing to the latest imgutil empty layer branch
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
* Updating imgutil version after PR#142 was merged
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
- Fixes cache images create with wrong format
- imgutil WithPlatform initializes OS-specific images
- Windows sim base layers are generated by imgutil instead of lifecycle
Signed-off-by: Micah Young <ymicah@vmware.com>
When using image cache, the commit of new cache deletes the old cache. There is a check for if there is a previous cache image, but that check was happenign after the new cache was written to that tag.
https://github.com/buildpacks/lifecycle/issues/453
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
With the reproducibility improvements, it often happens that the old and
new cache images are the same. The original image should not be
deleted in this case.
This is an issue with remote images, where the image is deleted by
digest and both the old and new images share the same digest.
Signed-off-by: Lukas Berger <bergerl@google.com>
* params prefer 'diffID' to 'sha' for specificity
* errors messages prefer 'SHA' to 'diffID' for consistency
* we should consider changing this convention this later
Signed-off-by: Emily Casey <ecasey@pivotal.io>
Switch cacher and restorer to use imgutil remote instead of local.
Make deleting the old cache image optional in image_cache commit.
This change depends on https://github.com/buildpack/imgutil/pull/10.
* Lock analyzed image and metadata for exporting
* Adds skip-layers flag to analyzer (analyzer now should run even when
cache is cleared)
Signed-off-by: Andrew Meyer <ameyer@pivotal.io>
Signed-off-by: Javier Romero <jromero@pivotal.io>
Signed-off-by: Emily Casey <ecasey@pivotal.io>
* compilation currently fails due to conflicting ggcr version in imgutil
Signed-off-by: Emily Casey <ecasey@pivotal.io>
Signed-off-by: Danny Joyce <djoyce@pivotal.io>
- Move logging into cacher/restorer rather than in cache implementations
- Remove scary warnings
- Remove cyclic dependencies
Signed-off-by: Andrew Meyer <ameyer@pivotal.io>
- Add cache interface
- Make image cache adhere to interface
- Add new volume cache implementation
Signed-off-by: Andrew Meyer <ameyer@pivotal.io>
Signed-off-by: Danny Joyce <djoyce@pivotal.io>