Skip to content

Add plugin create functionality. - #28164

Merged
vieux merged 1 commit into
moby:masterfrom
anusha-ragunathan:plugin-build
Nov 10, 2016
Merged

Add plugin create functionality.#28164
vieux merged 1 commit into
moby:masterfrom
anusha-ragunathan:plugin-build

Conversation

@anusha-ragunathan

Copy link
Copy Markdown
Contributor

- What I did
Add plugin create functionality.

- How I did it
Given a rootfs and a plugin manifest.json, create a plugin.

- How to verify it
Use docker plugin create to create the plugin. Once successfully create, you can enable it and use it. You can also docker plugin push to registry.

Signed-off-by: Anusha Ragunathan anusha@docker.com

@anusha-ragunathan

Copy link
Copy Markdown
Contributor Author

cc @vieux @tiborvass

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.

nit: ROOFS->ROOTFS

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.

:D

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.

ditto

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.

There is no description about rootfs in docs/extend/manifest.md. Can you add it?

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.

uh, I found that in docs/extend/index.md

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.

Should manifest be renamed? #28148

@vieux ^^

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.

I'll do it in #28148 if it ever get's merged. it's good like this for now

@AkihiroSuda

Copy link
Copy Markdown
Member

How about using an image instead of a raw rootfs directory?

e.g.

$ git clone https://github.com/vieux/docker-volume-sshfs
$ cd docker-volume-sshfs
$ docker build -t vieux/docker-volume-sshfs-image .
$ docker plugin create vieux/docker-volume-sshfs --manifest /somewhere/manifest.json vieux/docker-volume-sshfs-image 

@vieux

vieux commented Nov 8, 2016

Copy link
Copy Markdown
Contributor

@AkihiroSuda we discussed this already, we think it's a good idea, it's coming soon (in a separate PR)

@anusha-ragunathan
anusha-ragunathan force-pushed the plugin-build branch 3 times, most recently from 6ecf061 to d7591e6 Compare November 8, 2016 19:48
Comment thread plugin/v2/plugin.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.

@anusha-ragunathan won't this be logged twice ? once here and once in the calling function ?

@vieux

vieux commented Nov 8, 2016

Copy link
Copy Markdown
Contributor

LGTM ping @tiborvass

Comment thread cli/command/plugin/create.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.

why isn't this returning a simple error ?

Comment thread cli/command/plugin/create.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.

return err should be enough

@tiborvass

Copy link
Copy Markdown
Contributor

Apart from small optional nit, LGTM

@vieux

vieux commented Nov 9, 2016

Copy link
Copy Markdown
Contributor

ping @thaJeztah

@tiborvass

Copy link
Copy Markdown
Contributor

LGTM

@thaJeztah thaJeztah left a comment

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.

Comments inline

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.

Since this is an example, the header should be part of the example;

POST /plugins/plugin:latest/create HTTP/1.1
Content-Type: application/tar

{% raw %}
{{ TAR STREAM }}
{% endraw %}

Also can you check if application/tar or application/x-tar is the correct header? We use x-tar in other endpoints; https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api_v1.25.md#extract-an-archive-of-files-or-folders-to-a-directory-in-a-container

According to http://superuser.com/a/960710, there's still no official content-type for tar

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

application/tar is indeed not registered at http://www.iana.org/assignments/media-types/media-types.xhtml#application. Unregistered mime types are considered "experimental" and have an x- prefix. So it makes sense to replace with application/x-tar.

Ofcourse curl recognizes both types. Eg. curl -H "Content-Type: application/tar" -X POST http://localhost:9999/v1.25/plugins/testplugin/create --data-binary "@/tmp/pluginDir/context.tar"

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.

Yes, they probably work both. If it doesn't make a difference to us, then I prefer x-tar to be consistent

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.

This line can probably be removed if the example is updated

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.

this should be "plugin create (experimental)"

in the new docs rendering, this is actually used to create the H1 heading

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.

The page title should be removed for the new docs system (it's generated from the metadata)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. The last 3 comments apply across all plugin md files. @thaJeztah, is there a tool to run to check if the md files confirm to the new format? I ask because there might be a lot more across docker/docker.

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.

for the new docs, the [ and ] should be removed

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.

Should manifest be renamed? #28148

@vieux ^^

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.

should this be POST /plugins/create?name=<plugin name> instead? Feels odd to have an endpoint named after a not-yet existing resource.

/cc @bfirsh

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.

good point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@thaJeztah : that's what we have for other plugin endpoints such as enable, disable, push and set as well. I can either fix it just for create here, or make a follow-up PR to fix them all.

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.

@anusha-ragunathan it's fine for enable disable, it's an action on an existing resource. (container start and stop are the same)

but I see @thaJeztah's point, it's different for create, the resource doesn't yet exist. (same for image or container create, it's not in the URL)

@bfirsh bfirsh Nov 9, 2016

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.

👍 Standard REST for creating an object is POST /objects. The reasoning, I think:

  1. You are performing an action against the resource that is the set of plugins. The resource /plugins/name does not exist yet.
  2. Servers often generate an ID or name for you. (Not the case in this instance, but may as well be consistent.)
  3. Consistency. All REST APIs do this, so you kinda expect this to work.

Also worth noting that the endpoint is almost always POST /objects, not POST /objects/create, even though lots of our API does the latter. Depends whether you want to be consistent with the current world or a potential better future world! See also #25015.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@thaJeztah : I went ahead and updated endpoint to plugin/create/name=<>, after being convinced about the non-existent object endpoint.

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.

It should probably be /plugins/create?name=foo, as in with name as a GET parameter. To follow the reasoning in (1) above, that's performing an action against the resource /plugins/create, but with name as an additional option.

It would typically be in the request body, but in this case that's impossible.

(I would also argue this should be just POST /plugins, but I'm happy to fix this in one big go in #25015. ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bfirsh: +1 for tidying up all APIs URLs in one shot :)

@bfirsh

bfirsh commented Nov 9, 2016

Copy link
Copy Markdown
Contributor

Any chance you could also update api/swagger.yaml with the new endpoint? You can probably copy an existing endpoint and modify it. It looks pretty similar to /images/load, for example.

@anusha-ragunathan
anusha-ragunathan force-pushed the plugin-build branch 2 times, most recently from 185bfd2 to 7945c69 Compare November 9, 2016 22:59
@anusha-ragunathan

Copy link
Copy Markdown
Contributor Author

@bfirsh @thaJeztah : Updated with review comments on API. PTAL

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.

typo s/tagis/tag is/

@thaJeztah thaJeztah Nov 9, 2016

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.

Perhaps use the same as for image build;

- **name** - A name and optional tag to apply for the plugin in the `name:tag format`. 
  If you omit the `tag` the default `:latest` value is assumed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same review showing up thrice. fast fingers ? :)

@bfirsh bfirsh left a comment

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.

Nice, thanks! Looks like it was the old format, though – I've commented the fixes. :)

Comment thread api/swagger.yaml 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.

/plugins/create:

Comment thread api/swagger.yaml 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.

in: "query"

@thaJeztah thaJeztah left a comment

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.

one nit/suggestion, but LGTM otherwise

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.

oh, hold on: this should be prefixed with /v1.25 now

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.

same here (/v1.25)

@anusha-ragunathan
anusha-ragunathan force-pushed the plugin-build branch 2 times, most recently from 2978dac to 0828a01 Compare November 9, 2016 23:18
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
@anusha-ragunathan

Copy link
Copy Markdown
Contributor Author

@bfirsh @thaJeztah : updated

@thaJeztah thaJeztah left a comment

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.

thanks! LGTM!

@bfirsh

bfirsh commented Nov 10, 2016

Copy link
Copy Markdown
Contributor

swagger.yaml LGTM!

@thaJeztah

Copy link
Copy Markdown
Member

Do not merge until #27967 is merged

moving back to docs review to prevent trigger-happy's

@vieux
vieux merged commit 28a1ea3 into moby:master Nov 10, 2016
@anusha-ragunathan
anusha-ragunathan deleted the plugin-build branch November 10, 2016 17:00
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
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.

8 participants