dotnet / docker-tools

This is a repo to house some common tools for our various docker repos.
MIT License
122 stars 46 forks source link

ImageBuilder cannot generate MCR Tags Metadata for two images built with the same Dockerfile but different tags #1198

Closed lbussell closed 10 months ago

lbussell commented 10 months ago

While implementing https://github.com/dotnet/dotnet-docker/issues/5021, I tried to re-use the existing jammy-chiseled runtime and aspnet Dockerfiles but add an argument for specifying the variant of the base image, since there should be no difference to the Dockerfile content. Generating readmes fails for this scenario, I believe because of this code:

https://github.com/dotnet/docker-tools/blob/74f9169582bae470c771f7298820b40db7b9e8f7/src/Microsoft.DotNet.ImageBuilder/src/McrTagsMetadataGenerator.cs#L139-L150

Which would see that the platforms are matching and remove the matching doc info. This means when we add the McrTagsMetadata for the new tags, the new tags are ignored and thus readme generation fails.

I validated that changing the source Dockerfile fixes this.

Actual behavior

GENERATING MCR TAGS METADATA
----------------------------
Unhandled exception: System.InvalidOperationException: A value was not found for the variable '$(McrTagsYmlTagGroup:8.0-jammy-chiseled-extra-amd64)'
   at Microsoft.DotNet.ImageBuilder.ViewModel.VariableHelper.SubstituteValues(String expression, Func`3 getContextBasedSystemValue) in /image-builder/src/ViewModel/VariableHelper.cs:line 95
   at Microsoft.DotNet.ImageBuilder.McrTagsMetadataGenerator.Execute() in /image-builder/src/McrTagsMetadataGenerator.cs:line 57
   at Microsoft.DotNet.ImageBuilder.McrTagsMetadataGenerator.Execute(IGitService gitService, ManifestInfo manifest, RepoInfo repo, String sourceRepoUrl, String sourceBranch) in /image-builder/src/McrTagsMetadataGenerator.cs:line 29     
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateReadmesCommand.UpdateTagsListing(String readme, RepoInfo repo) in /image-builder/src/Commands/GenerateReadmesCommand.cs:line 112
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateReadmesCommand.<ExecuteAsync>b__6_8(String readmeContent, ValueTuple`2 context) in /image-builder/src/Commands/GenerateReadmesCommand.cs:line 57
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateArtifactsCommand`2.GenerateArtifactAsync[TContext](String templatePath, String artifactPath, TContext context, GetTemplateState`1 getState, String artifactName, Func`3 postProcess) in /image-builder/src/Commands/GenerateArtifactsCommand.cs:line 106
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateArtifactsCommand`2.GenerateArtifactsAsync[TContext](IEnumerable`1 contexts, Func`2 getTemplatePath, Func`2 getArtifactPath, GetTemplateState`1 getState, String templatePropertyName, String artifactName, Func`3 postProcess) in /image-builder/src/Commands/GenerateArtifactsCommand.cs:line 85
...
dotnet-issue-labeler[bot] commented 10 months ago

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

lbussell commented 10 months ago

[Triage] This is an issue but it isn't blocking anything at the moment, so we won't fix it at this time.