Don't hard-fail when the Docker credentials file isn't present
baronfel opened this issue · comments
Chet Husk commented
When running our tooling on a clean system, we fail with an exception trying to read the Docker config.json. This a) shouldn't be required for 'authentication-less' pulls like those from Docker Hub anyway, and b) should instead be surfaced in a 'we couldn't authenticate to this registry' error instead. So we should protect/recover from failures in the DockerCredsProvider library to sidestep this failure mode.
Stack trace from runtime exception
Microsoft.NET.Build.Containers.Credentials.CredentialRetrievalException: CONTAINER1008: Failed retrieving credentials for "registry.hub.docker.com": Docker config '/root/.docker/config.json' doesn't exist.
---> System.IO.FileNotFoundException: Docker config '/root/.docker/config.json' doesn't exist.
at Valleysoft.DockerCredsProvider.CredsProvider.GetCredStoreAsync(String registry, IFileSystem fileSystem, IProcessService processService, IEnvironment environment)
at Valleysoft.DockerCredsProvider.CredsProvider.GetCredentialsAsync(String registry, IFileSystem fileSystem, IProcessService processService, IEnvironment environment)
at Microsoft.NET.Build.Containers.AuthHandshakeMessageHandler.GetAuthenticationAsync(String registry, String scheme, Uri realm, String service, String scope, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs:line 107
--- End of inner exception stack trace ---
at Microsoft.NET.Build.Containers.AuthHandshakeMessageHandler.GetAuthenticationAsync(String registry, String scheme, Uri realm, String service, String scope, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs:line 111
at Microsoft.NET.Build.Containers.AuthHandshakeMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs:line 182
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Microsoft.NET.Build.Containers.Registry.GetManifestAsync(String repositoryName, String reference, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Registry.cs:line 202
at Microsoft.NET.Build.Containers.Registry.GetImageManifestAsync(String repositoryName, String reference, String runtimeIdentifier, String runtimeIdentifierGraphPath, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Registry.cs:line 130
at Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ExecuteAsync(CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs:line 49
at Microsoft.NET.Build.Containers.Tasks.CreateNewImage.Execute() in /_/src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs:line 32
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)