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

Make the ServerAddress optional for the main docker registry. #1315

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func NewAuthCreds(refHostname string) (AuthCreds, error) {
// - ac.ServerAddress: "https://index.docker.io/v1/".
if !isAuthConfigEmpty(ac) {
if authConfigHostname == registry.IndexServer {
Copy link
Member

@fahedouch fahedouch Aug 16, 2022

Choose a reason for hiding this comment

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

if ac.ServerAddress == "" {
ac.ServerAddress = registry.IndexServer
}

I think we should enforce the default registry when it is empty for all refHostname

if ac.ServerAddress != registry.IndexServer {
if ac.ServerAddress != "" && ac.ServerAddress != registry.IndexServer {
Copy link
Member

Choose a reason for hiding this comment

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

nit: To preserve the behaviour of printing the debug log on ac.ServerAddress == "", I think the if logic should be something like:

if ac.ServerAddress == "" {
	// This can happen with Amazon ECR: https://github.com/containerd/nerdctl/issues/733
	logrus.Debugf("failed to get ac.ServerAddress for authConfigHostname=%q (refHostname=%q)",
		authConfigHostname, refHostname)
} else if authConfigHostname == registry.IndexServer {
	if ac.ServerAddress != registry.IndexServer {
		return nil, fmt.Errorf("expected ac.ServerAddress (%q) to be %q", ac.ServerAddress, registry.IndexServer)
	}
} else {
	acsaHostname := credentials.ConvertToHostname(ac.ServerAddress)
	if acsaHostname != authConfigHostname {
		return nil, fmt.Errorf("expected the hostname part of ac.ServerAddress (%q) to be authConfigHostname=%q, got %q",
			ac.ServerAddress, authConfigHostname, acsaHostname)
	}
}

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@AkihiroSuda Yes, LGTM, and I've tested that it fixes the repro case specified in #1308 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, @ericpromislow is still away, so you won't get any feedback from him for at least another 10 days.

Copy link
Member

Choose a reason for hiding this comment

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

@jandubois Thanks for testing and providing the info

@ktock Please add your commit to this PR (or just open a new PR)?

return nil, fmt.Errorf("expected ac.ServerAddress (%q) to be %q", ac.ServerAddress, registry.IndexServer)
}
} else if ac.ServerAddress == "" {
Expand Down