-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
try http for docker manifest --insecure #2376
Conversation
cli/registry/client/client.go
Outdated
|
||
} else { | ||
return nil, ErrHTTPProto{OrigErr: err.Error()} | ||
} | ||
} | ||
} | ||
repoName, err := reference.WithName(repoEndpoint.Name()) |
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.
Looks like this check could be done even before we connect to the registry
cli/registry/client/client.go
Outdated
@@ -141,7 +141,22 @@ func (c *client) getRepositoryForReference(ctx context.Context, ref reference.Na | |||
httpTransport, err := c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint) | |||
if err != nil { | |||
if strings.Contains(err.Error(), "server gave HTTP response to HTTPS client") { |
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.
Looks like there's a small bug here, and we ignore any other error?
cli/registry/client/client.go
Outdated
@@ -141,7 +141,22 @@ func (c *client) getRepositoryForReference(ctx context.Context, ref reference.Na | |||
httpTransport, err := c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint) | |||
if err != nil { | |||
if strings.Contains(err.Error(), "server gave HTTP response to HTTPS client") { | |||
return nil, ErrHTTPProto{OrigErr: err.Error()} | |||
if repoEndpoint.endpoint.TLSConfig.InsecureSkipVerify { |
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.
Perhaps reverse the logic, and do an early return; with my other suggestions;
func (c *client) getRepositoryForReference(ctx context.Context, ref reference.Named, repoEndpoint repositoryEndpoint) (distribution.Repository, error) {
repoName, err := reference.WithName(repoEndpoint.Name())
if err != nil {
return nil, errors.Wrapf(err, "failed to parse repo name from %s", ref)
}
httpTransport, err := c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint)
if err != nil {
if !strings.Contains(err.Error(), "server gave HTTP response to HTTPS client") {
return nil, err
}
if !repoEndpoint.endpoint.TLSConfig.InsecureSkipVerify {
return nil, ErrHTTPProto{OrigErr: err.Error()}
}
// --insecure was set; fall back to plain HTTP
if url := repoEndpoint.endpoint.URL; url != nil && url.Scheme == "https" {
url.Scheme = "http"
httpTransport, err = c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint)
if err != nil {
return nil, err
}
}
}
return distributionclient.NewRepository(repoName, repoEndpoint.BaseURL(), httpTransport)
}
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.
Modified according to your suggestion.
Thanks.
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! the changes look ok, but could you:
- squash the commits (so that there's a single commit in this PR)
- update the commit message (there's a typo, and it may be good to describe this is for the
manifest
commands)
let me know if you need help doing so 👍
Signed-off-by: Tengfei Wang <tfwang@alauda.io>
Hi @thaJeztah, |
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.
Whoops, thought I left my review already, but looks like I didn't submit it
LGTM
@silvin-lubecki PTAL |
Guys! Merge this Please! |
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.
LGTM
- What I did
fixes #1631
- How I did it
Add retry for http when https not work
- How to verify it
docker manifest push --insecure 127.0.0.1:5000/test:v1
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)