[go: up one dir, main page]

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

Ipv6 registries #3489

Merged
merged 1 commit into from
Jul 25, 2022
Merged

Ipv6 registries #3489

merged 1 commit into from
Jul 25, 2022

Conversation

aojea
Copy link
Contributor
@aojea aojea commented Aug 24, 2021

registry: support ipv6 addresses

Current registry reference use a subset of dns and IPv4 addresses to
represent a registry domain.
Since registries are mostly compatible with rfc3986, that defines the
URI generic syntax, this adds support for IPv6 enclosed in squared
brackets based on the mentioned rfc, but excluding zone identifiers
as defined by rfc6874 or special addresses such as IPv4-Mapped)

Ref: kubernetes/kubernetes#104491

This builds on top of previous PRs

Kudos to those persons for showing the path

@aojea aojea force-pushed the ipv6_domains branch 4 times, most recently from aea8f78 to f963818 Compare August 24, 2021 21:45
@aojea
Copy link
Contributor Author
aojea commented Aug 24, 2021

Since this was reported in Kubernetes, I'd prefer the whole ecosystem to be consistent about registries URIs, rather than fix it in Kubernetes only.
cc :@dims @mikebrow @thaJeztah

@thaJeztah
Copy link
Member

Also wondering if we can use net.SplitHostPort() for these 🤔 https://pkg.go.dev/net#SplitHostPort

@aojea
Copy link
Contributor Author
aojea commented Aug 24, 2021

Also wondering if we can use net.SplitHostPort() for these https://pkg.go.dev/net#SplitHostPort

I used the regex based on current state and previous PRs, but I rather prefer to validate with the golang stdlib functions if possible, it seems less error prone (unless stdlib changes of course, but this only happened in 1.17 for ipv4 addresses)

@thaJeztah
Copy link
Member

Yes, perhaps there's other reasons for the regexes that I didn't think of, but I saw them, and know that it's easy to make a mistake in regexes (besides them known to be potentially more power-hungry), so if possible, using stdlib, that would be my preference.

Of course that's orthogonal to the " the whole ecosystem to be consistent about registries URIs, rather than fix it in Kubernetes only." question

For that, given that currently, IPv4[:<port>] is accepted, I (personally) see no reason why the same shouldn't be supported for IPv6. Assuming, of course it doesn't conflict with existing expectations, but (first glance) this PR is only adding more test-cases, and all existing tests continue to pass, so it looks solid.

@milosgajdos
Copy link
Member

can you please rebase @aojea

@aojea
Copy link
Contributor Author
aojea commented Apr 7, 2022

can you please rebase @aojea

@milosgajdos rebased :)

@milosgajdos milosgajdos added this to the Registry/3.0.0 milestone Apr 23, 2022
@aojea
Copy link
Contributor Author
aojea commented Apr 27, 2022

it needs other approval, right?

@milosgajdos
Copy link
Member

yeah, pinging @thaJeztah

@milosgajdos
Copy link
Member

CC: @wy65701436 @deleteriousEffect

Copy link
Contributor
@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

see comments

reference/reference.go Outdated Show resolved Hide resolved
reference/reference.go Outdated Show resolved Hide resolved
reference/regexp.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link
codecov-commenter commented Jun 23, 2022

Codecov Report

Merging #3489 (d897a19) into main (3e4f8a0) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #3489   +/-   ##
=======================================
  Coverage   56.58%   56.58%           
=======================================
  Files         103      103           
  Lines        7520     7520           
=======================================
  Hits         4255     4255           
  Misses       2596     2596           
  Partials      669      669           
Impacted Files Coverage Δ
....com/distribution/distribution/reference/regexp.go 83.33% <0.00%> (ø)
...m/distribution/distribution/reference/reference.go 78.83% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e4f8a0...d897a19. Read the comment docs.

@thaJeztah
Copy link
Member

Let me post my comment form #3667 here as well

my concern in that one specifically (but partially this one as well), is the huge dependency on more-and-more complex regexes; I know there's been efforts to simplify them (as they are notorious for being a resource-hog).

From that perspective (but I'd have to have a closer look at how they're all used), I'd rather have a "good enough" regex to split the elements, followed by a "regular" check to make further determination, e.g.;

  1. split first element if it contains a ., a [ or a : (in which case we "assume" it's a hostname or IP-address)
  2. call net.SplitHostPort (and/or other functions) to perform more specific validation

With that, we avoid running a (likely) heavy regex for each use and will be able to return a more specific error message ("port out of range"), instead of "invalid reference".

@aojea
Copy link
Contributor Author
aojea commented Jun 23, 2022

/hold

let me work in the stdlib approach, I do prefer that too, this IPv6 regex is not something easier to think about

@aojea
Copy link
Contributor Author
aojea commented Jun 25, 2022

ok, it seems I had a misconception, we don't need full validation, as @thaJeztah says we just need a simpler regex

I was comparing with golang url.Parse and it doesn't perform validation too
https://go.dev/play/p/D0m9NZ1AMJL

@aojea
Copy link
Contributor Author
aojea commented Jun 25, 2022

I think I'm close now, just missing the referenceRegex

@aojea aojea force-pushed the ipv6_domains branch 2 times, most recently from 70061f3 to d897a19 Compare June 25, 2022 16:12
@aojea
Copy link
Contributor Author
aojea commented Jun 25, 2022

I think I'm close now, just missing the referenceRegex

Ok, this is ready

Ipv4 has dots and digits, that are valid repository names, ipv6 has invalid character for repository names.
However both ipv6 and ipv4.will be valid domains

@aojea
Copy link
Contributor Author
aojea commented Jun 25, 2022

/hold cancel

Current registry reference use a subset of dns and IPv4 addresses to
represent a registry domain.

Since registries are mostly compatible with rfc3986, that defines the
URI generic syntax, this adds support for IPv6 enclosed in squared
brackets based on the mentioned rfc.

The regexp is only expanded to match on IPv6 addreses enclosed between
square brackets, considering only regular IPv6 addresses represented
as compressed or uncompressed, excluding special IPv6 address
representations.

Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
@aojea
Copy link
Contributor Author
aojea commented Jun 30, 2022

@thaJeztah @mikebrow @milosgajdos

the current approach is consistent with the golang url.Parse implementation, it just parses without validation,

Copy link
Member
@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

we should look at changing some of these variables to const's and see if we need all those utility functions (in favor of just plain string concatenating)

@aojea
Copy link
Contributor Author
aojea commented Jul 19, 2022

@milosgajdos I'm not familiar with the workflow here, what is missing?

@milosgajdos
Copy link
Member

@aojea sorry for the radio silence on my end. LGTM.

@milosgajdos milosgajdos merged commit 4bf3547 into distribution:main Jul 25, 2022
@aojea
Copy link
Contributor Author
aojea commented Jul 25, 2022

@aojea sorry for the radio silence on my end. LGTM.

no worries,

thanks so much

@aojea
Copy link
Contributor Author
aojea commented Jul 25, 2022

by the way, how often do you use to release, so I can revendor it in kubernetes to fix kubernetes/kubernetes#104491

@milosgajdos
Copy link
Member

We don't have a regular cadence. main is currently set up to become v3 but for that we'll have to have a proper release plan which is not quite the case at the moment. I shall try and put something together, though I wouldn't expect that to become the reality earlier than the EOY 😞

@aojea
Copy link
Contributor Author
aojea commented Jul 25, 2022

Fair enough

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.

5 participants