-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Resolve ambiguity on registry v2 ping #10227
Conversation
can you add a test? we have the registry tests now |
// Ensure it supports the v2 Registry API. | ||
var supportsV2 bool | ||
|
||
for _, versionName := range resp.Header[http.CanonicalHeaderKey("Docker-Distribution-API-Version")] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if it is such an old registry it doesnt have this header, will it panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will range over a nil slice, which is safe, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://groups.google.com/forum/#!topic/golang-nuts/gVgVLQU1FFE
On Tue, Jan 20, 2015 at 3:40 PM, Josh Hawn [email protected] wrote:
In registry/endpoint.go
#10227 (comment):@@ -227,6 +227,21 @@ func (e *Endpoint) pingV2() (RegistryInfo, error) {
}
defer resp.Body.Close()
- // The endpoint may have multiple supported versions.
- // Ensure it supports the v2 Registry API.
- var supportsV2 bool
- for _, versionName := range resp.Header[http.CanonicalHeaderKey("Docker-Distribution-API-Version")] {
it will range over a nil slice, which is safe, right?
—
Reply to this email directly or view it on GitHub
https://github.com/docker/docker/pull/10227/files#r23266959.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's safe (accessing an unknown key from a map returns the default value for the mapped type, and it's safe to range
over a nil
slice).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok cool can we still have a test 😈
not for the range thing but for the ping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlhawn This might be too late: this loop is only iterating over the instances of the Docker-Distribution-API-Version
. There needs to be a split on space for this to work correctly in the future.
For example, this only supports this:
Docker-Distribution-API-Version: registry/2.0
Docker-Distribution-API-Version: registry/2.1
When it should support this:
Docker-Distribution-API-Version: registry/2.0 registry/2.1
This will keep 1.5 sufficiently future proof.
And even this:
Docker-Distribution-API-Version: registry/2.0 registry/2.1
Docker-Distribution-API-Version: registry/1.0
I confirm this works and fixed my problem with But please address @jfrazelle's concern |
29d59d8
to
22debc6
Compare
LGTM |
tested locally with the dockerfile change |
@jlhawn @jfrazelle I still have https://gist.github.com/tiborvass/70954869930b67c6a929 locally. |
That seems unrelated to this patch? Hmmm On Tuesday, January 20, 2015, Tibor Vass [email protected] wrote:
|
@jfrazelle @tiborvass: @tianon is helping me update this so it doesn't require the libtrust changes! 👏 |
/me is very excite On Tue, Jan 20, 2015 at 7:36 PM, Josh Hawn [email protected] wrote:
|
22debc6
to
5dd7fa8
Compare
Black market PR for you, sir: jlhawn#3 |
(for those following along at home, the Godeps in github.com/docker/distribution is new as of 8 days ago, which is why we weren't using this trick before now 🎉) |
🎈 🍰 🎂 |
is there a way to get rid of that merge commit? idk... but testing |
6d57079
to
0ff357a
Compare
v2 ping now checks for a Docker-Distribution-API-Version header that identifies the endpoint as "registry/2.0" Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
Update our "registry" install to use the included Godeps libraries so that it doesn't require anything from our current source (hence moving it up for better caching too) Signed-off-by: Andrew "Tianon" Page <[email protected]>
0ff357a
to
681f4d8
Compare
Yeah a rebase will do it. |
@jfrazelle I rebased the merge commit out ... and I made @tianon's title shorter. I HAD TO >_> |
ie, docker pull --rebase origin master |
Muahahahaha |
LGTM |
whoa i beat drone |
which will fail anyways bc of the dockerfile |
I just started my |
all clear for me! |
🎆 |
LGTM |
Resolve ambiguity on registry v2 ping
v2 ping now checks for a Docker-Distribution-API-Version
header that identifies the endpoint as "registry/2.0"
fixes #10226