Skip to content

Remove unnecessary Docker login from CleanAcrImagesCommand#2044

Merged
lbussell merged 1 commit intodotnet:mainfrom
lbussell:fix-cleanup
Mar 24, 2026
Merged

Remove unnecessary Docker login from CleanAcrImagesCommand#2044
lbussell merged 1 commit intodotnet:mainfrom
lbussell:fix-cleanup

Conversation

@lbussell
Copy link
Copy Markdown
Member

The cleanup command wrapped operations in ExecuteWithCredentialsAsync, which tried to Docker-login using the registry's service connection from publishConfig.RegistryAuthentication. That service connection was not referenced in the pipeline stage, causing Azure DevOps to refuse OIDC token issuance.

The Docker login was unnecessary - all ACR operations authenticate directly via cleanServiceConnection through the Azure SDK. Removing the wrapper and the unused IRegistryCredentialsProvider dependency should fix the pipeline failure.

Fixes #2028

The cleanup command wrapped operations in ExecuteWithCredentialsAsync,
which tried to Docker-login using the registry's service connection from
publishConfig.RegistryAuthentication. That service connection was not
referenced in the pipeline stage, causing Azure DevOps to refuse OIDC
token issuance.

The Docker login was unnecessary - all ACR operations authenticate
directly via cleanServiceConnection through the Azure SDK. Removing the
wrapper and the unused IRegistryCredentialsProvider dependency fixes the
pipeline failure.

Fixes dotnet#2028

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lbussell lbussell requested a review from a team as a code owner March 23, 2026 22:10
@lbussell lbussell merged commit fb308a5 into dotnet:main Mar 24, 2026
12 checks passed
@lbussell lbussell deleted the fix-cleanup branch March 24, 2026 16:11
@gdams
Copy link
Copy Markdown
Member

gdams commented Mar 30, 2026

This seems to have broken our cleanup pipeline now as the oras discover command still requires auth. That said I'm assuming that #2050 should resolve this issue @lbussell?

   at Microsoft.DotNet.ImageBuilder.Commands.CleanAcrImagesCommand.<>c__DisplayClass12_0.<<ProcessManifestsAsync>b__0>d.MoveNext() in /image-builder/ImageBuilder/Commands/CleanAcrImagesCommand.cs:line 168
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.<>c__53`1.<<ForEachAsync>b__53_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.ImageBuilder.Commands.CleanAcrImagesCommand.ProcessManifestsAsync(IAcrClient acrClient, IAcrContentClient acrContentClient, List`1 deletedImages, List`1 deletedRepos, ContainerRepository repository, Func`2 canDeleteManifest) in /image-builder/ImageBuilder/Commands/CleanAcrImagesCommand.cs:line 166
   at Microsoft.DotNet.ImageBuilder.Commands.CleanAcrImagesCommand.ProcessRepoAsync(IAcrClient acrClient, IAcrContentClient acrContentClient, ContainerRepository repository, List`1 deletedRepos, List`1 deletedImages) in /image-builder/ImageBuilder/Commands/CleanAcrImagesCommand.cs:line 96
   at Microsoft.DotNet.ImageBuilder.Commands.CleanAcrImagesCommand.ExecuteAsync() in /image-builder/ImageBuilder/Commands/CleanAcrImagesCommand.cs:line 81
   at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__21_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__22_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()

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.

cleanup-acr-images pipeline fails with missing service connection reference

3 participants