Skip to content

Update engine api with required arguments#21657

Merged
calavera merged 2 commits into
moby:masterfrom
vdemeester:update-engine-api
Apr 19, 2016
Merged

Update engine api with required arguments#21657
calavera merged 2 commits into
moby:masterfrom
vdemeester:update-engine-api

Conversation

@vdemeester

Copy link
Copy Markdown
Member

This PR is related to docker/engine-ap#162 and is it's inclusion in docker/docker. It's still a little bit a work in progress but I wanted to have both PR opened at the same time to make sure it's ok for everybody and to measure the impact of the change on the code here 👼.

The docker-archive-public/docker.engine-api#162 (docker-archive-public/docker.engine-api#137 for the related issue) changes some client signature to add the required arguments in the signature (to make it easier to use by telling the consumer what is required and what is not) 🐯.

It also tries to remove the image/tag distinction from the client side for now, and replace it with the reference instead.
This has some impact on the content trust code (api/client/trust.go).

This is also a very small step to remove the reference package (or at least reduce the usage) from this repository (and use docker/distribution/reference in the future, once distribution/distribution#1277 is merged) 🐳.

/cc @calavera @stevvooe @MHBauer @dmcgowan @aaronlehmann @tonistiigi @LK4D4

It's a little bit a chicken-and-egg problem, as depending on the review here, the code in the API will have to be updated. Anyway, we have to wait for docker-archive-public/docker.engine-api#162 to get merged first but we will merge it once it's green, reviewed and OK here 👼 .

Let's hope it's green first 😅.

🐸

Comment thread api/client/import.go Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This message is there since at least 1.8, so I think it could be removed. If yes, then the tag variable is no more needed and the Tag attribute in ImageImportOptions neither.

@thaJeztah

Copy link
Copy Markdown
Member

Looks like CI is failing:

16:15:28 + go test -check.f DockerSuite -check.v -check.timeout=90m -test.timeout=360m github.com/docker/docker/integration-cli
16:15:57 # github.com/docker/docker/integration-cli
16:15:57 ./docker_api_network_test.go:32: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:47: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:51: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:103: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:129: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:173: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:186: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:199: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:212: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:214: unknown "github.com/docker/engine-api/types".NetworkCreate field 'Name' in struct literal
16:15:57 ./docker_api_network_test.go:214: too many errors

@thaJeztah thaJeztah added the status/failing-ci Indicates that the PR in its current state fails the test suite label Mar 30, 2016
@vdemeester vdemeester force-pushed the update-engine-api branch 2 times, most recently from 0f4441d to 27a8c82 Compare March 30, 2016 16:45
Comment thread api/client/push.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why is this removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh you are right, something is missing in the ImagePush in remote API (the same check done in ImageTag in fact)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this resolved?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@aaronlehmann

Copy link
Copy Markdown

I like the direction this is going. My main question is about references being passed as strings into engine-api functions. Would it be better to use the actual distribution/reference types? I see cases where we're taking a parsed reference and calling String before passing it to an API function, and then the API function parses it again. I also see arguments like repoInfo.Name()+"@"+r.digest.String().

I think there are advantages to passing in actual references to the API functions. It prevents you from making mistakes like passing in a tag where you're really supposed to pass a fully-qualified reference.

Are there reasons not to expose these types at the API level? Or do we plan to do that, with this PR as an intermediate step on the way there?

@stevvooe WDYT?

@stevvooe

Copy link
Copy Markdown
Contributor

@aaronlehmann I'm not sure that the distribution/reference types are ready for prime time. We are still seeing issues with their use in docker/docker. While they provide correctness, they are slightly clunky for common API use. I'd rather people just take a string user input and shove it into this function, where we can validate and parse it correctly.

I think there are advantages to passing in actual references to the API functions. It prevents you from making mistakes like passing in a tag where you're really supposed to pass a fully-qualified reference.

Are there reasons not to expose these types at the API level? Or do we plan to do that, with this PR as an intermediate step on the way there?

I agree 100% with the sentiment here but we may want to consider this PR to be an intermediate step.

Ideally, these all become completely server-side, avoiding the need to parse and validate them client-side.

@vdemeester

Copy link
Copy Markdown
Member Author

Are there reasons not to expose these types at the API level? Or do we plan to do that, with this PR as an intermediate step on the way there?

I agree with @stevvooe, "Ideally, these all become completely server-side, avoiding the need to parse and validate them client-side.". It make it simpler for a user of the engine-api to use it (like in libcompose) and it's kinda consistent with the cli (in the way that you specify the image reference as a "string" on its own on the cli, should be the same using the api).

And yes, I see this PR as a first step on moving towards having the reference parsing handling server-side (but it's a little more work and it would make the PR bigger).

@vdemeester vdemeester force-pushed the update-engine-api branch 2 times, most recently from 46ae5f2 to 2db3c07 Compare March 31, 2016 12:48
@vdemeester

Copy link
Copy Markdown
Member Author

Updated the code (here and in the engine-api PR) and fixed the build 😸

@aaronlehmann aaronlehmann removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Mar 31, 2016
@vdemeester vdemeester force-pushed the update-engine-api branch 3 times, most recently from 04c3702 to bc1658c Compare April 12, 2016 15:48
@calavera

Copy link
Copy Markdown
Contributor

@vdemeester the change in engine-api was merged this morning. Feel free to update this PR. Moving to code review.

@vdemeester

Copy link
Copy Markdown
Member Author

Updated.

Win2Lin is green :

11:15:29 23cd6eeee6e6
11:15:39 INFO: Cleanup complete
11:15:39 Notifying endpoint 'HTTP:https://leeroy.dockerproject.org/notification/jenkins'
11:15:39 Finished: SUCCESS

Userns is not 😓

11:11:50 ----------------------------------------------------------------------
11:11:50 FAIL: docker_cli_run_unix_test.go:808: DockerSuite.TestRunSeccompProfileDenyUnshareUserns
11:11:50 
11:11:50 docker_cli_run_unix_test.go:839:
11:11:50     c.Fatalf("expected unshare userns with seccomp profile denied to fail, got %s", out)
11:11:50 ... Error: expected unshare userns with seccomp profile denied to fail, got /go/src/github.com/docker/docker/bundles/1.11.0-dev/test-integration-cli/../binary/docker: Error response from daemon: Untar re-exec error: exit status 1: output: no such file or directory.
11:11:50 See '/go/src/github.com/docker/docker/bundles/1.11.0-dev/test-integration-cli/../binary/docker run --help'.
11:11:50 
11:11:50 
11:11:50 
11:11:50 ----------------------------------------------------------------------

@vdemeester vdemeester changed the title WIP: Update engine api with required arguments Update engine api with required arguments Apr 13, 2016
@calavera

Copy link
Copy Markdown
Contributor

LGTM

Comment thread api/client/trust.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we not have a way to assemble canonical references? https://godoc.org/github.com/docker/distribution/reference#WithDigest

May have to use the docker/docker/reference version.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hum you're right

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Using new methods from engine-api, that make it clearer which element is
required when consuming the API.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@vdemeester

Copy link
Copy Markdown
Member Author

@stevvooe updated (using WithDigest from docker/docker/reference for now – as it's already used elsewhere in this file)

@stevvooe

Copy link
Copy Markdown
Contributor

LGTM

@calavera calavera merged commit 7fd53f7 into moby:master Apr 19, 2016
@vdemeester vdemeester deleted the update-engine-api branch April 19, 2016 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants