Skip to content

Conversation

wjordan
Copy link
Contributor

@wjordan wjordan commented Aug 14, 2025

Fixes issue

N/A (I didn't create a separate issue)

Describe the change

Adds a ns query param to registry mirror requests. This matches the behavior of Containerd's own Registry Host Namespace implementation, and has become a common convention in registry-server implementations providing mirror functionality.

How to verify it

Perform a registry request against a configured mirror (where the host does not match the namespace), and verify that the request includes the ns query parameter corresponding to the namespace.

Changelog text

  • Add "ns" query param to registry mirror requests.

Please verify and check that the pull request fulfills the following requirements

  • Tests have been added or not applicable
  • Documentation has been added, updated, or not applicable
  • Changes have been rebased to main
  • Multiple commits to the same code have been squashed

Copy link
Contributor

@sudo-bmitch sudo-bmitch left a comment

Choose a reason for hiding this comment

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

I believe this needs to compare hostnames, since it's possible for two configs to point to the same hostname. For testing, that will require spinning up a second httptest Server to get a unique hostname (different port number).

Note, this is associated with opencontainers/distribution-spec#66 and in the future I'm going to want to add some default proxy settings that would check the OCI-Namespace header in the responses. But that shouldn't stop this from moving forward.

}
if h != reqHost {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if h != reqHost {
if h.Config.Hostname != reqHost.config.Hostname {

}
if h != reqHost {
query.Set("ns", reqHost.config.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
query.Set("ns", reqHost.config.Name)
query.Set("ns", reqHost.config.Hostname)

Signed-off-by: Will Jordan <will.jordan@gmail.com>
@wjordan
Copy link
Contributor Author

wjordan commented Aug 15, 2025

Updated the PR with the suggested change and an updated test, please take a look.

Thanks for linking the associated issue, I knew it was an established convention but wasn't aware of the ongoing discussion for inclusion in the distribution spec. My specific use-case is for compatibility with a Spegel mirror which was mentioned in that thread.

@wjordan wjordan requested a review from sudo-bmitch August 15, 2025 15:54
Copy link
Contributor

@sudo-bmitch sudo-bmitch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@sudo-bmitch sudo-bmitch merged commit 2c34a73 into regclient:main Aug 15, 2025
4 checks passed
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.

2 participants