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

V2 registry fallback #18

Open
wants to merge 4 commits into
base: v2-registry
Choose a base branch
from
Open

V2 registry fallback #18

wants to merge 4 commits into from

Conversation

dmcgowan
Copy link
Owner

Add support for fallback to v1 on push

An HTTP header "Docker-Command" is added to specify the command as "push". When the server returns a 404 from the v2 endpoint, the client should fallback to v1 and push to the v1 endpoint.

@stevvooe
Copy link
Collaborator

LGTM!

@dmcgowan
Copy link
Owner Author

@stevvooe I fixed up your commit to get it to compile, was expected a string array instead of just a string, see []string{"push"}

Tested and it does fallback when endpoint not found is returned, still need to test when /v2/ returns a 404

@stevvooe
Copy link
Collaborator

@dmcgowan Sounds great. Do you need a registry that has this behavior or can you mock with net/http or nginx?

@dmcgowan
Copy link
Owner Author

@stevvooe the plan right now is to mock it. The only way I have tested so far is to force the error through altering the code.

dmcgowan and others added 4 commits January 16, 2015 15:39
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
To allow remotes to understand the operation being carried out during an API
request to the registry, we've added a header indicating the engine command.
Mostly, this is advisory but a registry may take action based on the field.

This changeset only adds this for the "push" command.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
@dmcgowan
Copy link
Owner Author

Tested and added a fix to an error discovered in testing. Tested using nginx in front of a v1 and v2 registry and forcing a 404 when the push header is given.

// present, the remote may act on the field but this is mostly advisory.
metaHeaders["Docker-Command"] = []string{"push"}

repoInfo.Index.Headers = metaHeaders
Copy link
Collaborator

Choose a reason for hiding this comment

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

Subtle.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Dirty. I really don't like it but doing it right will require (imo) the refactor we discussed, having the endpoint be the top level value from which sessions and factories are derived.

@stevvooe
Copy link
Collaborator

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants