Skip to content

Conversation

@tofay
Copy link
Contributor

@tofay tofay commented Jul 21, 2022

If a container image has a image.base.ref.name of scratch then determine that there is no base image, rather than trying to pull "scratch".

In v1.1.9 component-detection tries to pull the "scratch@" image, which fails causing the following log to be displayed:

 [INFO] Base image scratch@ could not be found locally and could not be pulled. Results will not be mapped to base image layers 

In v1.2.4 component-detection still tries to pull the "scratch@" image but this time the TryPullImageAsync call at

await DockerService.TryPullImageAsync(refWithDigest, cancellationToken)))
must be succeeding, as component-detection doesn't omit that log, but subsequently hits an error like

[WARN] Scanning of image sha256:26f452efc71ea50bb61043de65c4fbbfcda3677ca6f013690898bfd286f22081 failed with exception: Object reference not set to an instance of an object. 

Looking at the changes between those releases, possibly the bump of Docker.Dotnet from 3.125.4 to 3.124.5 caused this change of behaviour. I can't verify that easily though as I'm hitting dotnet/Docker.DotNet#554, hence the bump to Docker.Dotnet to 3.125.10

Anyway, it seems sensible to special case scratch in this case.

If a container image has a image.base.ref.name of scratch then
determine that there is no base image, rather than trying to pull
"scratch".

Signed-off-by: Tom Fay <tomfay@microsoft.com>
@tofay tofay requested a review from a team as a code owner July 21, 2022 05:07
@tofay tofay requested a review from chsalgado July 21, 2022 05:07
@grvillic
Copy link
Collaborator

@tofay - Thanks for the contribution! Would you mind adding a test for this change to prevent regressions?

Signed-off-by: Tom Fay <tomfay@microsoft.com>
@tofay
Copy link
Contributor Author

tofay commented Jul 21, 2022

@tofay - Thanks for the contribution! Would you mind adding a test for this change to prevent regressions?

Added a UT for this.

@tofay tofay requested a review from grvillic July 27, 2022 07:14
@JamieMagee JamieMagee enabled auto-merge (squash) August 4, 2022 17:40
@github-actions

This comment was marked as outdated.

@JamieMagee JamieMagee merged commit f659027 into main Aug 4, 2022
@JamieMagee JamieMagee deleted the tofay/fix-scratch-based-image branch August 4, 2022 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants