[sonic-package-manager]: Unpin docker-image-py and use lowercase 'azure/sonic' in registry test#4655
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
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 insonic_package_manager/registry.pyand use it inRegistryResolverand 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). |
| if domain == reference.DEFAULT_DOMAIN and '/' not in remainder: | ||
| remainder = reference.OFFICIAL_REPO_NAME + '/' + remainder | ||
| return domain, remainder |
| 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') |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
|
|
@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! |
@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? |
|
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. |
|
Got it. Then let's pin the docker-image-py to 0.1.13 as a quick fix. |
a6311f2 to
068b234
Compare
|
/azp run |
|
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>
068b234 to
810f7ad
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Cherry-pick PR to 202511: #4674 |
|
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. |
|
Cherry-pick PR to msft-202608: Azure/sonic-utilities.msft#394 |
What I did
docker-image-pywas pulled in unpinned (docker-image-py>=0.1.10). When 0.2.0 was released (2026-06-29) it changedReference.split_docker_domain()to treat an uppercase first path component as a registry domain (Docker Hub repository names must be lowercase). This broketests/sonic_package_manager/test_registry.py::test_get_registry_for, which resolved the referenceAzure/sonic.The key point is that
Azure/sonicis 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 pinningdocker-image-pyto==0.1.13(#4660) or reimplementingsplit_docker_domain(), this change simply fixes the test to use the valid lowercase referenceazure/sonicand drops the pin (>=0.1.10), so registry resolution and the test are correct regardless of the installeddocker-image-pyversion and the build can adopt 0.2.0. It pairs with sonic-net/sonic-buildimage#28144, which stops installingpython3-regexvia apt so 0.2.0'sregex>=2026.6.28installs cleanly.How I did it
setup.py:docker-image-py==0.1.13→docker-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-py0.2.0 installed:It passes (CI green) —
azure/sonicresolves to theDockerHubRegistrysingleton regardless of thedocker-image-pyversion.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.