Skip to content
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

Image caching fix for locally built images #1518

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

mthalman
Copy link
Member

@mthalman mthalman commented Dec 12, 2024

Fixes #1516

In the scenario where this issue was discovered, it was the runtime image whose base runtime-deps image was being inspected to determine whether it had changed. So it was querying the registry the runtime-deps digest instead of accounting for the new locally built version of runtime-deps. Since runtime-deps was rebuilt then runtime should also be rebuilt. But since it had the digest from the registry and that matched what was in the image info, then it just used the cached image for runtime.

This fixes the logic by accounting for two different scenarios. In the build scenario, all base images will have either been built locally (if they are .NET base images) or pre-emptively pulled. Prior to this fix, the logic was not accounting for a locally built image at all and would always query the registry. So for build, it should check for the local image. But for the matrix generation command, there are no builds happening so it must query the registry all the time to get the digest.

Related: #1517

@mthalman mthalman requested a review from a team as a code owner December 12, 2024 17:12
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

1 similar comment
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@@ -1125,7 +1132,7 @@ public async Task BuildCommand_Caching(
localImageDigestResults:
[
new($"{runtimeDepsRepoQualified}:{tag}", runtimeDepsDigest),
new($"{overridePrefix}{runtimeDepsRepo}:{tag}", runtimeDepsDigest),
new($"{overridePrefix}{runtimeDepsRepo}:{tag}", runtimeDepsDigest, OnCallCount: 2),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for only returning this on the second call now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first call should return null to simulate it's locally built and doesn't have a digest yet. Later during the build, after a push, it calls it again and now it should have the digest.

@mthalman mthalman merged commit 825ab97 into dotnet:main Dec 12, 2024
12 checks passed
@mthalman mthalman deleted the image-cache branch December 12, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependent images are cached and not re-built when their base image's Dockerfile is changed
2 participants