-
Notifications
You must be signed in to change notification settings - Fork 611
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
Fixes 404 error when authenticating with v2 reg #724
Fixes 404 error when authenticating with v2 reg #724
Conversation
@@ -253,6 +253,12 @@ func tryLoginWithRegHost(ctx context.Context, rh docker.RegistryHost) error { | |||
Host: rh.Host, | |||
Path: rh.Path, | |||
} | |||
if rh.Path == "/v2" { |
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.
if !strings.HasSuffix(rh.Path, "/") {
rh.Path += "/"
This way you avoid hard-coded v2
in the code. Don't you think?
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.
Thanks I'd forgotten about HasSuffix from that package - looks like this PR will be closed off and merged elsewhere but that would be a better approach
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.
@AkihiroSuda @alisson276 I'm looking at this suggestion and I'm not sure to implement seems a good change but as far as I can tell the login issues are only affecting v2 and adding this applies it to every version of registry - Would it be best to just apply the leading slash to /v2 only or globally?
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.
I think just checking if rh.Path == "/v2"
is fine.
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.
I just think that keep in sync with the containerd library is not a good idea. If, for any reason, they change that path, it must be synced here. If you are worried about always adding a slash, the safest approach is to try twice: first using the rh.Path (no matter what it is, if v2, v3, whatever) and if fails, do a second try appending the slash at the end (IMO).
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.
If I correctly understood, in the PR they are asking to add this explicit in the GET call... in other words, do a:
req, err := http.NewRequest(http.MethodGet, u.String() + "/", nil)
So, this if
is ok, I just don't know if fixing the v2
is a good idea, but this is just my opinion. I'm just trying to contribute because this problem afftects my environment too.
In docker CLI it doesn't happen. do you know how this is handled there?
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.
@alisson276 v2 is part of the docker registry specification which I think is pretty static and as far as I know unlikely to change but it maybe a valid concern in future - with regards to doesn't happen with Docker question docker uses the dockerd daemon and not containerd directly as well as using /v1 and not /v2. This might explain the difference
Thanks, I'm closing this, as we now have containerd/containerd#6470 |
Reopened per discussion in containerd/containerd#6470 . |
Signed-off-by: Dylan Scott <dylanrhysscott@gmail.com>
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.
Thanks
After applying this fix I can successfully authenticate with github registry
This maybe a slightly naive approach so welcome feedback on a better place for this - Not sure who to ping from containerd
Closes #715