feat(daemon): lazy image saving#1121
Merged
jonjohnsonjr merged 4 commits intogoogle:mainfrom Sep 19, 2021
knqyf263:daemon_lazy_loading
Merged
feat(daemon): lazy image saving#1121jonjohnsonjr merged 4 commits intogoogle:mainfrom knqyf263:daemon_lazy_loading
jonjohnsonjr merged 4 commits intogoogle:mainfrom
knqyf263:daemon_lazy_loading
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1121 +/- ##
==========================================
- Coverage 75.16% 75.06% -0.11%
==========================================
Files 108 108
Lines 7724 7800 +76
==========================================
+ Hits 5806 5855 +49
- Misses 1363 1380 +17
- Partials 555 565 +10
Continue to review full report at Codecov.
|
pkg/v1/daemon/image.go
Outdated
| if err := i.initialize(); err != nil { | ||
| return nil, err | ||
| } | ||
| return i.tarballImage.LayerByDigest(h) |
Collaborator
There was a problem hiding this comment.
Should be LayerByDiffID
Collaborator
|
LGTM in general other than the one bug. I would like to see a test (you should be able to catch most issues by calling |
Contributor
Author
|
@jonjohnsonjr Thanks for the review! I fixed the bug and added |
jonjohnsonjr
approved these changes
Sep 19, 2021
Collaborator
|
Thanks! |
This was referenced Sep 21, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #627
A faster way of getting an image ID is really useful for caching. We don't want to call
docker saveif we already have the image information in the cache. For example, in our case, we should skip scanning vulnerabilities of the image when the scan result exists in the cache. The cache key is an image ID, so it is enough to calldocker inspectto know only the image ID.This implementation is based on
computed()as below.go-containerregistry/pkg/v1/mutate/image.go
Line 51 in 45aaa6c
The downside is that
daemon.Imagedoesn't return an error and it might return an error when each method is called (knqyf263@881e16e).I probably should add tests, but I'd like to hear your thought on this idea before working on tests 🙇
I also want to replace
ConfigFilewith this approach in another PR because I think we can generate the config file from the result ofdocker inspectanddocker history.