dotnet / docker-tools

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

Matrix trimming doesn't handle deletion of Dockerfiles from manifest #1481

Closed mthalman closed 4 weeks ago

mthalman commented 1 month ago

In the scenario where a Dockerfile is deleted from the manifest and matrix trimming is enabled, it will cause a similar error to this in the generateBuildMatrix command:

Unhandled exception: System.InvalidOperationException: Unable to find matching platform in manifest for platform 'src/windowsservercore/ltsc2019/webassembly/amd64/Dockerfile-amd64-Windows-windowsservercore-ltsc2019-'.
   at Microsoft.DotNet.ImageBuilder.ImageInfoHelper.LoadFromContent(String imageInfoContent, ManifestInfo manifest, Boolean skipManifestValidation, Boolean useFilteredManifest) in /image-builder/src/ImageInfoHelper.cs:line 174
   at Microsoft.DotNet.ImageBuilder.ImageInfoHelper.LoadFromFile(String path, ManifestInfo manifest, Boolean skipManifestValidation, Boolean useFilteredManifest) in /image-builder/src/ImageInfoHelper.cs:line 194
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateBuildMatrixCommand.<>c__DisplayClass7_0.<.ctor>b__0() in /image-builder/src/Commands/GenerateBuildMatrixCommand.cs:line 39
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateBuildMatrixCommand.GetPlatformsAsync() in /image-builder/src/Commands/GenerateBuildMatrixCommand.cs:line 412
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateBuildMatrixCommand.GenerateMatrixInfoAsync() in /image-builder/src/Commands/GenerateBuildMatrixCommand.cs:line 491
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateBuildMatrixCommand.ExecuteAsync() in /image-builder/src/Commands/GenerateBuildMatrixCommand.cs:line 57

Example build

This happens because the current state of the image info file does have that Dockerfile defined in it, but the manifest does not. The default behavior of ImageInfoHelper.LoadFromContent is to validate and throw in this case. Instead, it should skip manifest validation.

dotnet-issue-labeler[bot] commented 1 month 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.

dotnet-issue-labeler[bot] commented 1 month 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.