-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧹 split loading container images from opening connections #3237
Conversation
Test Results768 tests ±0 768 ✅ ±0 24s ⏱️ -1s Results for commit e4ae430. ± Comparison against base commit 8ff1bae. This pull request removes 6 and adds 6 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
var img v1.Image | ||
var rc io.ReadCloser | ||
loadedImage := false | ||
if asset.Connections[0].Options != nil { | ||
if _, ok := asset.Connections[0].Options[COMPRESSED_IMAGE]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find the place where this is set. Previously, it was set in L212.
I got errors when running this with a registry scan.
|
The same for a single image:
|
69e89b1
to
f40630d
Compare
I made a mistake in the code. I fixed it now and it seems to be working as expected. Also rebased on @czunker please re-test |
I tried both the registry and a single image. Both worked and also cleaned up the images. But I'm not sure whether this is working as intended. When scanning a single image, it still removes two temporary files at the end:
From the PR description, I'd only expected one such message. |
this is intended. This is the first step in fixing the issue. With this change we split off the image pull and we only pull it if we try to do anything with it (not before that). Currently, we try to detect the OS during discovery, which triggers the pulling of the image (because we resolve the OS by looking through the filesystem of the container. After this PR is in we will make sure OS isn't detected during discovery. This will be a special behaviour of scanning containers. The OS will be filled in only during a scan, not during discovery. With that approach, we will be pulling the container at scan time and clean it up directly after the scan. One caveat in that approach is that for container images we would have to call |
loadedImage := false | ||
if asset.Connections[0].Options != nil { | ||
if _, ok := asset.Connections[0].Options[COMPRESSED_IMAGE]; ok { | ||
var rc io.ReadCloser | ||
// read image from disk | ||
img, rc, err = image.LoadImageFromDisk(asset.Connections[0].Options[COMPRESSED_IMAGE]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's set right here
Signed-off-by: Ivan Milchev <[email protected]>
Signed-off-by: Ivan Milchev <[email protected]>
Signed-off-by: Ivan Milchev <[email protected]>
Signed-off-by: Ivan Milchev <[email protected]>
Signed-off-by: Ivan Milchev <[email protected]>
Signed-off-by: Ivan Milchev <[email protected]>
e1aeff4
to
e4ae430
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @imilchev
Signed-off-by: Ivan Milchev <[email protected]>
split loading of containers to a point after connecting. Creating the connection shouldn't be as expensive as it currently is