Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/resolver: Fix insecure mirrors #4293

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

vvoland
Copy link
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
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
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.

@vvoland vvoland mentioned this pull request Sep 29, 2023
26 tasks
@tonistiigi tonistiigi merged commit b9fcd76 into moby:master Sep 29, 2023
56 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.

4 participants