Skip to content

fix(secrets): match Docker Hub aliases when reading credentials from Docker config - #1865

Open
m86hussein wants to merge 1 commit into
flyteorg:mainfrom
m86hussein:fix/docker-config-registry-aliases
Open

m86hussein wants to merge 1 commit into
flyteorg:mainfrom
m86hussein:fix/docker-config-registry-aliases

Conversation

@m86hussein

Copy link
Copy Markdown
Contributor

Problem

flyte create secret <name> --type image_pull --from-docker-config --registries ... calls create_dockerconfigjson_from_config, which looked each requested registry up by exact auths key. docker login stores Docker Hub as https://index.docker.io/v1/, so:

  • --registries docker.io fails with No credentials could be extracted for registries: docker.io.
  • The command's documented example --registries ghcr.io,docker.io only logs a warning and creates a secret without the Docker Hub credentials.
  • With a credsStore/credHelpers, the helper was queried with docker.io rather than the key the credentials are stored under.

Fix

Add _resolve_auths_key, which returns the exact auths key if present. Otherwise it returns the first key with the same normalized host, using the existing _normalize_registry that infer_registry_from_docker_config already relies on. That key is then used for the direct auth lookup, the credential-helper lookup/query, and the key emitted in the secret. Hub therefore stays under https://index.docker.io/v1/, which is also kubectl 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.io against a config with https://index.docker.io/v1/ returns both credentials.
  • test_create_dockerconfigjson_from_config_queries_helper_with_stored_key: with credsStore, the helper is called with https://index.docker.io/v1/.

Both fail on main (2 failed, 27 passed) and pass with the fix. tests/utils/test_docker_credentials.py plus the CLI secret/docker tests: 68 passed. ruff check/ruff format --check are clean.

Fixes flyteorg/flyte#8452

…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

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@6df18e4). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/flyte/_utils/docker_credentials.py 81.25% 1 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1865   +/-   ##
=======================================
  Coverage        ?   74.07%           
=======================================
  Files           ?      350           
  Lines           ?    44749           
  Branches        ?     7096           
=======================================
  Hits            ?    33147           
  Misses          ?     9764           
  Partials        ?     1838           
Files with missing lines Coverage Δ
src/flyte/_utils/docker_credentials.py 79.50% <81.25%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[BUG] [V2] flyte create secret --from-docker-config --registries docker.io misses Docker Hub credentials stored by docker login

1 participant