Closed mthalman closed 4 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.
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.
Fixes #1350
The changes from https://github.com/dotnet/docker-tools/pull/1321 don't work for long-running jobs. The presumption was that the necessary tokens would be retrieved up front when Image Builder runs a command. (It's necessary for the token to be retrieved right away while we still have a valid OIDC token from the pipeline. If you wait too long the OIDC token will expire, preventing you from retrieving any access tokens with it.) But this isn't true for the
build
command. It retrieves a token for theAzureScopes.ContainerRegistryScope
scope at the end of the build when querying for digests of the pushed images. This is the first time an attempt is made to get a token for that scope. So no cached token exists for that scope. But by this point the OIDC token from the pipeline is expired, causing the error.The solution is to simply prepopulate the cache by making a request to get the token for that scope at the beginning of the
build
command.