Skip to content

util/resolver: Fix insecure mirrors#4293

Merged
tonistiigi merged 1 commit intomoby:masterfrom
vvoland:fix-mirrors-hostname
Sep 29, 2023
Merged

util/resolver: Fix insecure mirrors#4293
tonistiigi merged 1 commit intomoby:masterfrom
vvoland:fix-mirrors-hostname

Conversation

@vvoland
Copy link
Copy Markdown
Collaborator

@vvoland vvoland commented Sep 29, 2023

Mirrors in RegistryConfig.Mirrors can be specified using a full URL (schema, trailing slashes) but registries in the input map are keyed by their hostname.

Previous code used the mirror URL as key which resulted in an empty RegistryConfig being passed to the fillInsecureOpts function and didn't set the insecure options.

Use Host part of the parsed registry as a key instead.

Mirrors in `RegistryConfig.Mirrors` can be specified using a full URL
(schema, trailing slashes) but registries in the input map are keyed by
their hostname.

Previous code used the mirror URL as key which resulted in an empty
`RegistryConfig` being passed to the `fillInsecureOpts` function and
didn't set the insecure options.

Use Host part of the parsed registry as a key instead.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland
Copy link
Copy Markdown
Collaborator Author

vvoland commented Sep 29, 2023

Context: The mirrors in Docker were broken after this PR: moby/moby#45992

Actually, there are 2 issues:

  1. The above PR removed the code that left only host part of the URL in the Mirrors. Which in combination with the Buildkit code before this PR, made it pick the empty RegistryConfig (fixed by this PR).
    I was considering if we should restore that code on Moby side instead, but looking at util/resolver/resolver_test.go, looks like Buildkit also accepts full URLs as mirrors?

  2. Moby side - Mirrors property was lost (fixed by daemon/RegistryHosts: Don't lose mirrors moby#46565)

@crazy-max crazy-max added this to the v0.12.3 milestone Sep 29, 2023
Comment on lines +133 to +136
for _, rawMirror := range c.Mirrors {
h := newMirrorRegistryHost(rawMirror)
mirrorHost := h.Host
hosts, err := fillInsecureOpts(mirrorHost, m[mirrorHost], h)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok I think I understand this :)

This fix LGTM - since RegistryConfig always supported multiple URLs, this code was always wrong then? And just didn't ever appear, since we were never using it in this way from moby.

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.

4 participants