Skip to content

[sonic-package-manager]: Unpin docker-image-py and use lowercase 'azure/sonic' in registry test#4655

Merged
yijingyan2 merged 1 commit into
sonic-net:masterfrom
lunyue-ms:lunyue/adapt-docker-image-py-020
Jul 10, 2026
Merged

[sonic-package-manager]: Unpin docker-image-py and use lowercase 'azure/sonic' in registry test#4655
yijingyan2 merged 1 commit into
sonic-net:masterfrom
lunyue-ms:lunyue/adapt-docker-image-py-020

Conversation

@lunyue-ms

@lunyue-ms lunyue-ms commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What I did

docker-image-py was pulled in unpinned (docker-image-py>=0.1.10). When 0.2.0 was released (2026-06-29) it changed Reference.split_docker_domain() to treat an uppercase first path component as a registry domain (Docker Hub repository names must be lowercase). This broke tests/sonic_package_manager/test_registry.py::test_get_registry_for, which resolved the reference Azure/sonic.

The key point is that Azure/sonic is not a valid Docker Hub reference in the first place — Docker Hub namespaces must be lowercase (Azure/... is rejected as an invalid namespace). So instead of pinning docker-image-py to ==0.1.13 (#4660) or reimplementing split_docker_domain(), this change simply fixes the test to use the valid lowercase reference azure/sonic and drops the pin (>=0.1.10), so registry resolution and the test are correct regardless of the installed docker-image-py version and the build can adopt 0.2.0. It pairs with sonic-net/sonic-buildimage#28144, which stops installing python3-regex via apt so 0.2.0's regex>=2026.6.28 installs cleanly.

How I did it

  • setup.py: docker-image-py==0.1.13docker-image-py>=0.1.10 (drop the pin added in [setup]: Pin docker-image-py to 0.1.13 #4660).
  • tests/sonic_package_manager/test_registry.py: resolver.get_registry_for('Azure/sonic')resolver.get_registry_for('azure/sonic').

How to verify it

Run the package-manager registry test with docker-image-py 0.2.0 installed:

pytest tests/sonic_package_manager/test_registry.py::test_get_registry_for

It passes (CI green) — azure/sonic resolves to the DockerHubRegistry singleton regardless of the docker-image-py version.

Previous command output (if the output of a command-line utility has changed)

N/A - no user-facing command output changes.

New command output (if the output of a command-line utility has changed)

N/A - no user-facing command output changes.

Copilot AI review requested due to automatic review settings June 30, 2026 01:57
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates sonic-package-manager to be resilient to docker-image-py 0.2.0’s change in Reference.split_docker_domain() by introducing a local split_docker_domain() implementation (restoring the pre-0.2.0 heuristic) and routing registry operations through it, ensuring mixed-case repository paths (e.g., Azure/...) aren’t misinterpreted as registry domains.

Changes:

  • Add a local split_docker_domain() helper in sonic_package_manager/registry.py and use it in RegistryResolver and registry API calls.
  • Extend unit tests to validate Docker Hub resolution for additional repository inputs and validate the split behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sonic_package_manager/registry.py Adds a local domain-splitting helper and switches registry resolution and API calls to use it.
tests/sonic_package_manager/test_registry.py Adds/extends tests for Docker Hub resolution and split behavior (including uppercase repo path preservation).

Comment thread sonic_package_manager/registry.py Outdated
Comment on lines +32 to +34
if domain == reference.DEFAULT_DOMAIN and '/' not in remainder:
remainder = reference.OFFICIAL_REPO_NAME + '/' + remainder
return domain, remainder
Comment on lines +26 to +28
assert split_docker_domain('Azure/docker-test') == ('docker.io', 'Azure/docker-test')
assert split_docker_domain('debian') == ('docker.io', 'library/debian')
assert split_docker_domain('registry-server.com/docker') == ('registry-server.com', 'docker')
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@lunyue-ms lunyue-ms requested a review from qiluo-msft June 30, 2026 02:50
@roeebar-arista

roeebar-arista commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

sonic-buildimage has docker-image-py pinned to 0.1.13. Any reason why sonic-utilities is different, and pull changes asynchronously?

@lunyue-ms lunyue-ms requested a review from stepanblyschak July 1, 2026 01:19
@lunyue-ms

Copy link
Copy Markdown
Contributor Author

@stepanblyschak, could you please review this change? It adapts the registry domain split to be compatible with docker-image-py v0.2.0. Since you originally authored this logic, your review would be much appreciated. Thanks!

@lunyue-ms

Copy link
Copy Markdown
Contributor Author

sonic-buildimage has docker-image-py pinned to 0.1.13. Any reason why sonic-utilities is different, and pull changes asynchronously?

@roeebar-arista , sorry for missed your comments before adding stepanblyschak. buildimage pins 0.1.13 for the image build, but sonic-utilities' own CI installs deps from PyPI via pip install ".[testing]" (unpinned docker-image-py>=0.1.10), so it floated to 0.2.0 and broke test_get_registry_for. Looks like recent pr-checkers for sonic-utility were failed after 6-29 for the same reason. Should we pin the version to 0.1.13 (#4660) or do some adaption work in this PR?

@roeebar-arista

Copy link
Copy Markdown
Contributor

I think it is generally better to pin package versions and upgrade them in a controlled way, rather than having sonic-utilities break when async package updates happen.

As a quick fix, maybe we should pin docker-image-py to 0.1.13 and upgrade to 0.2 later, if and when it is needed. I see you already submitted #4660.

@lunyue-ms

lunyue-ms commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Got it. Then let's pin the docker-image-py to 0.1.13 as a quick fix.

@lunyue-ms lunyue-ms force-pushed the lunyue/adapt-docker-image-py-020 branch from a6311f2 to 068b234 Compare July 10, 2026 00:50
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

…re/sonic' in registry test

docker-image-py 0.2.0 changed split_docker_domain() to treat an uppercase first
path component as a registry domain (Docker Hub repository names must be
lowercase), which broke test_get_registry_for on the invalid reference
'Azure/sonic'.

Instead of pinning docker-image-py to ==0.1.13, revert setup.py back to
>=0.1.10 and fix the test to use the valid lowercase Docker Hub reference
'azure/sonic', so registry resolution and the test are correct regardless of
the installed docker-image-py version.

Signed-off-by: Lun Yue <17232861+lunyue-ms@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lunyue-ms lunyue-ms force-pushed the lunyue/adapt-docker-image-py-020 branch from 068b234 to 810f7ad Compare July 10, 2026 00:58
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@lunyue-ms lunyue-ms changed the title [sonic-package-manager]: Make registry domain split independent of do… [sonic-package-manager]: Unpin docker-image-py and use lowercase 'azure/sonic' in registry test Jul 10, 2026
@yijingyan2 yijingyan2 merged commit c759035 into sonic-net:master Jul 10, 2026
9 checks passed
@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202511: #4674

@saiarcot895

Copy link
Copy Markdown
Contributor

For later reference:

If a image name starts with an uppercase character, it's used as the registry domain. If it starts with a lowercase character, the default registry is used, with a namespace of the first part of the image name.

admin@vlab-03:~$ docker push Azure/docker-dhcp-relay
Using default tag: latest
The push refers to repository [Azure/docker-dhcp-relay]
Get "https://Azure/v2/": context deadline exceeded
admin@vlab-03:~$ docker tag docker-dhcp-relay:latest azure/docker-dhcp-relay:latest
admin@vlab-03:~$ docker push azure/docker-dhcp-relay
Using default tag: latest
The push refers to repository [docker.io/azure/docker-dhcp-relay]

@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to msft-202608: Azure/sonic-utilities.msft#394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants