Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle parallel calls to docker login with osxkeychain #333

Open
beejeebus opened this issue Aug 8, 2024 · 0 comments
Open

Handle parallel calls to docker login with osxkeychain #333

beejeebus opened this issue Aug 8, 2024 · 0 comments

Comments

@beejeebus
Copy link

beejeebus commented Aug 8, 2024

When docker login private-registry.example.com is called in parallel, some of the calls fail with the error The specified item already exists in the keychain.

Assuming a docker config with osxkeychain:

$ jq .credsStore ~/.docker/config.json
"osxkeychain"
$ jq .auths ~/.docker/config.json
{
  "private-registry.example.com": {}
}

Then the issue can be reproduced like this:

~ $ (docker login private-registry.example.com &) && (docker login private-registry.example.com &) && docker login private-registry.example.com
Authenticating with existing credentials...
Authenticating with existing credentials...
Authenticating with existing credentials...
Error saving credentials: error storing credentials - err: exit status 1, out: `The specified item already exists in the keychain.`
Error saving credentials: error storing credentials - err: exit status 1, out: `The specified item already exists in the keychain.`
Login Succeeded

The processes that lose the race report an error, even though the credentials were successfully added by the winner of the race.

beejeebus pushed a commit to beejeebus/docker-credential-helpers that referenced this issue Aug 8, 2024
When `docker login` is called in parallel, some of the calls fail with the
error `The specified item already exists in the keychain`.

This PR checks for this specific error in `osxkeychain.Add` and returns
ok. If one process loses the race in this case, the desired credentials
were saved by another process and we can ignore the error.
beejeebus pushed a commit to beejeebus/docker-credential-helpers that referenced this issue Aug 8, 2024
When `docker login` is called in parallel, some of the calls fail with the
error `The specified item already exists in the keychain`.

This PR checks for this specific error in `osxkeychain.Add` and returns
ok. If one process loses the race in this case, the desired credentials
were saved by another process and we can ignore the error.

Signed-off-by: Justin Randell <[email protected]>
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

No branches or pull requests

1 participant