1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #28512 from anusha-ragunathan/fix_enable

Cleanup after plugin install.
This commit is contained in:
Sebastiaan van Stijn 2016-11-17 10:16:47 +01:00 committed by GitHub
commit a58e3e7fef
2 changed files with 10 additions and 3 deletions

View file

@ -10,7 +10,7 @@ import (
) )
// PluginInstall installs a plugin // PluginInstall installs a plugin
func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) error { func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (err error) {
// FIXME(vdemeester) name is a ref, we might want to parse/validate it here. // FIXME(vdemeester) name is a ref, we might want to parse/validate it here.
query := url.Values{} query := url.Values{}
query.Set("name", name) query.Set("name", name)
@ -27,6 +27,14 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types
ensureReaderClosed(resp) ensureReaderClosed(resp)
return err return err
} }
defer func() {
if err != nil {
delResp, _ := cli.delete(ctx, "/plugins/"+name, nil, nil)
ensureReaderClosed(delResp)
}
}()
var privileges types.PluginPrivileges var privileges types.PluginPrivileges
if err := json.NewDecoder(resp.body).Decode(&privileges); err != nil { if err := json.NewDecoder(resp.body).Decode(&privileges); err != nil {
ensureReaderClosed(resp) ensureReaderClosed(resp)
@ -40,8 +48,6 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types
return err return err
} }
if !accept { if !accept {
resp, _ := cli.delete(ctx, "/plugins/"+name, nil, nil)
ensureReaderClosed(resp)
return pluginPermissionDenied{name} return pluginPermissionDenied{name}
} }
} }

View file

@ -36,6 +36,7 @@ func (pm *Manager) enable(p *v2.Plugin, force bool) error {
p.Lock() p.Lock()
p.Restart = false p.Restart = false
p.Unlock() p.Unlock()
shutdownPlugin(p, pm.containerdClient)
return err return err
} }