Repository navigation
fix(secrets): match Docker Hub aliases when reading credentials from Docker config - #1865
Open
m86hussein wants to merge 1 commit into
Open
m86hussein wants to merge 1 commit into
m86hussein wants to merge 1 commit into
Conversation
…Docker config create_dockerconfigjson_from_config looked requested registries up by exact auths key, but docker login stores Docker Hub as https://index.docker.io/v1/. --registries docker.io therefore failed, and the documented --registries ghcr.io,docker.io silently produced a secret without Hub credentials. Resolve each registry to its auths key by normalized host (exact key first) and use that key for direct auth, the credential helper and the emitted secret. Fixes flyteorg/flyte#8452 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Mohamed Hussein <317587333+m86hussein@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1865 +/- ##
=======================================
Coverage ? 74.07%
=======================================
Files ? 350
Lines ? 44749
Branches ? 7096
=======================================
Hits ? 33147
Misses ? 9764
Partials ? 1838
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
flyte create secret <name> --type image_pull --from-docker-config --registries ...callscreate_dockerconfigjson_from_config, which looked each requested registry up by exactauthskey.docker loginstores Docker Hub ashttps://index.docker.io/v1/, so:--registries docker.iofails withNo credentials could be extracted for registries: docker.io.--registries ghcr.io,docker.ioonly logs a warning and creates a secret without the Docker Hub credentials.credsStore/credHelpers, the helper was queried withdocker.iorather than the key the credentials are stored under.Fix
Add
_resolve_auths_key, which returns the exactauthskey if present. Otherwise it returns the first key with the same normalized host, using the existing_normalize_registrythatinfer_registry_from_docker_configalready relies on. That key is then used for the directauthlookup, the credential-helper lookup/query, and the key emitted in the secret. Hub therefore stays underhttps://index.docker.io/v1/, which is alsokubectl create secret docker-registry's default. Exact keys keep precedence, so existing configs behave as before.Tests
New tests in
tests/utils/test_docker_credentials.py:test_create_dockerconfigjson_from_config_matches_docker_hub_alias:ghcr.io,docker.ioagainst a config withhttps://index.docker.io/v1/returns both credentials.test_create_dockerconfigjson_from_config_queries_helper_with_stored_key: withcredsStore, the helper is called withhttps://index.docker.io/v1/.Both fail on
main(2 failed, 27 passed) and pass with the fix.tests/utils/test_docker_credentials.pyplus the CLI secret/docker tests: 68 passed.ruff check/ruff format --checkare clean.Fixes flyteorg/flyte#8452