dotnet / docker-tools

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

Fix dry run handling in generateEolAnnotationData #1438

Closed mthalman closed 1 month ago

mthalman commented 2 months ago

The following exception occurs when executing the generateEolAnnotationData command with dry run enabled:

Error occurred while generating EOL annotation data: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Microsoft.DotNet.ImageBuilder.Commands.RegistryOptions.ApplyOverrideToDigest(String fullyQualifiedDigest, String repoName) in /image-builder/src/Commands/RegistryOptions.cs:line 31
   at Microsoft.DotNet.ImageBuilder.ImageInfoHelper.ApplyRegistryOverride(ImageArtifactDetails imageInfo, RegistryOptions overrideOptions) in /image-builder/src/ImageInfoHelper.cs:line 48
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateEolAnnotationDataCommand.GetDigestsToAnnotate() in /image-builder/src/Commands/GenerateEolAnnotationDataCommand.cs:line 95
Unhandled exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Microsoft.DotNet.ImageBuilder.Commands.RegistryOptions.ApplyOverrideToDigest(String fullyQualifiedDigest, String repoName) in /image-builder/src/Commands/RegistryOptions.cs:line 31
   at Microsoft.DotNet.ImageBuilder.ImageInfoHelper.ApplyRegistryOverride(ImageArtifactDetails imageInfo, RegistryOptions overrideOptions) in /image-builder/src/ImageInfoHelper.cs:line 48
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateEolAnnotationDataCommand.GetDigestsToAnnotate() in /image-builder/src/Commands/GenerateEolAnnotationDataCommand.cs:line 95
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateEolAnnotationDataCommand.<ExecuteAsync>b__11_0() in /image-builder/src/Commands/GenerateEolAnnotationDataCommand.cs:line 59
   at Microsoft.DotNet.ImageBuilder.RegistryCredentialsProviderExtensions.ExecuteWithCredentialsAsync(IRegistryCredentialsProvider credsProvider, Boolean isDryRun, Func`1 action, RegistryCredentialsOptions credentialsOptions, String registryName, String ownedAcr) in /image-builder/src/RegistryCredentialsProviderExtensions.cs:line 30
   at Microsoft.DotNet.ImageBuilder.Commands.GenerateEolAnnotationDataCommand.ExecuteAsync() in /image-builder/src/Commands/GenerateEolAnnotationDataCommand.cs:line 57

This occurs because the input image info file contains empty digest values, which is expected in a dry run. But the logic for applying a registry override to those values expect them to be fully qualified digest values. So that logic should be skipped.

dotnet-issue-labeler[bot] commented 2 months ago

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.

dotnet-issue-labeler[bot] commented 2 months ago

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.