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

refactor plugin install #28963

Merged
merged 2 commits into from
Dec 5, 2016
Merged

Conversation

vieux
Copy link
Contributor

@vieux vieux commented Nov 30, 2016

before

calling /pull was pulling, installing a plugin, then a lists a privileges was returned.
upon a user accepting the privileges, it would enable the plugin.

problems:

  • the plugin was installed before the user accepted the privileges.
  • <ctrl-c> the "do you accept privileges" question would leave the plugin installed on the daemon
  • the whole privileges concept was entirely client side

now

calling /privileges will return the list of privileges required by the plugin (noting is installed)
update a user accepting the privileges, /pull is called with the list of privileges accepted
the daemon now compares the required privileges and the privileges sent by the user before installing

it forces a round-trip so even through the API there is an acceptance mechanism

ping @tiborvass @anusha-ragunathan

@AkihiroSuda
Copy link
Member

Compilation failing for windows

02:09:46 Building: bundles/1.14.0-dev/cross/windows/amd64/dockerd-1.14.0-dev.exe
02:11:05 # github.com/docker/docker/cmd/dockerd
02:11:05 cmd/dockerd/daemon.go:474: cannot use "github.com/docker/docker/plugin".GetManager() (type *"github.com/docker/docker/plugin".Manager) as type "github.com/docker/docker/api/server/router/plugin".Backend in argument to "github.com/docker/docker/api/server/router/plugin".NewRouter:
02:11:05 	*"github.com/docker/docker/plugin".Manager does not implement "github.com/docker/docker/api/server/router/plugin".Backend (missing Privileges method)

@vdemeester vdemeester added the status/failing-ci Indicates that the PR in its current state fails the test suite label Nov 30, 2016
@LK4D4
Copy link
Contributor

LK4D4 commented Nov 30, 2016

@vieux psst

@vieux
Copy link
Contributor Author

vieux commented Nov 30, 2016

@LK4D4 thanks

@vieux
Copy link
Contributor Author

vieux commented Dec 1, 2016

ping @tiborvass @anusha-ragunathan

@vieux vieux removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Dec 1, 2016
@vieux vieux force-pushed the refactor_plugin_install branch 2 times, most recently from aef8096 to c7b0481 Compare December 2, 2016 02:03
@@ -65,7 +74,12 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types
return cli.PluginEnable(ctx, name, types.PluginEnableOptions{Timeout: 0})
}

func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) {
func (cli *Client) tryPluginGetPrivileges(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can be tryPluginPrivileges to be consistent with other client function names.

@@ -177,7 +177,6 @@ func WritePullData(pd PullData, dest string, extract bool) error {
if err := json.Unmarshal(config, &p); err != nil {
return err
}
logrus.Debugf("%#v", p)
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets keep this. Its useful to look at the payload during debugging.

/plugins/privileges:
get:
summary: "Get plugin privileges"
operationId: "GetPluginsPrivileges"
Copy link
Contributor

Choose a reason for hiding this comment

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

Its a single plugin. So GetPluginPrivileges

$ref: "#/definitions/ErrorResponse"
parameters:
- name: "name"
in: "query"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to produce a human readable engine-api docs out of this. According to instructions on https://github.com/docker/docker/blob/master/api/README.md, I need to Copy api/swagger.yaml in this repository to engine/api/[VERSION_NUMBER]/swagger.yaml in the documentation repository.

Interestingly, there's no such file in https://github.com/docker/docker.github.io. How did you verify this doc, @vieux ?

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.

@mstanleyjones @bfirsh : Vendoring the swagger.yaml frequently to the docs repo is supposed to generate a human readable API reference, yes? Few questions:

  • How frequent is this vendoring?
  • When and where can I get the 1.25 api reference doc? We have to send the link to a few partners working on plugins and there's no such doc in any repo at the moment. @khudgins

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. The latest version for a particular version is vendored automatically on every deploy. There has been some back and forth between whether this should be pinned to a commit or automatically the latest, so that might change.
  2. As @cpuguy83 says, Add make command for previewing API docs #29078 should help you there. :)


if p, _ := pm.pluginStore.GetByName(name); p != nil {
Copy link
Contributor

@anusha-ragunathan anusha-ragunathan Dec 2, 2016

Choose a reason for hiding this comment

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

We should keep this check in Pull to avoid a race where another client has already pulled the plugin by now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pull is calling pull that is doing this check.

}

priv, err := pm.pull(ref, metaHeader, authConfig, pluginID)
if err != nil {
removePluginDir := func() {
Copy link
Contributor

@anusha-ragunathan anusha-ragunathan Dec 2, 2016

Choose a reason for hiding this comment

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

Its more elegant if we change this to a defer that acts on a named return error. Then we can remove L182 and L189.

defer func() {
		if err != nil {
			os.RemoveAll(pluginDir)...
		}
}()

Signed-off-by: Victor Vieux <[email protected]>
Signed-off-by: Victor Vieux <[email protected]>
@vieux
Copy link
Contributor Author

vieux commented Dec 2, 2016

@anusha-ragunathan PTAL

@anusha-ragunathan
Copy link
Contributor

LGTM (if tests pass)

@tiborvass
Copy link
Contributor

LGTM

@tiborvass tiborvass merged commit 1c96879 into moby:master Dec 5, 2016
@vieux vieux deleted the refactor_plugin_install branch December 13, 2016 01:26
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.

9 participants