From 84e58e2f89b3dea30738f92edcabef4336d0cff6 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Thu, 8 Sep 2016 18:52:29 -0700 Subject: [PATCH] plugins: do not try to contact disabled plugin Signed-off-by: Tibor Vass --- plugin/store/store.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/store/store.go b/plugin/store/store.go index b2cec91afe..d764060204 100644 --- a/plugin/store/store.go +++ b/plugin/store/store.go @@ -126,7 +126,7 @@ func (ps *Store) updatePluginDB() error { return nil } -// Get returns a plugin matching the given name and capability. +// Get returns an enabled plugin matching the given name and capability. func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlugin, error) { var ( p *v2.Plugin @@ -151,7 +151,12 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug p.Lock() p.RefCount += mode p.Unlock() - return p.FilterByCap(capability) + if p.IsEnabled() { + return p.FilterByCap(capability) + } + // Plugin was found but it is disabled, so we should not fall back to legacy plugins + // but we should error out right away + return nil, ErrNotFound(fullName) } if _, ok := err.(ErrNotFound); !ok { return nil, err @@ -170,7 +175,7 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug return nil, err } -// GetAllByCap returns a list of plugins matching the given capability. +// GetAllByCap returns a list of enabled plugins matching the given capability. func (ps *Store) GetAllByCap(capability string) ([]plugingetter.CompatPlugin, error) { result := make([]plugingetter.CompatPlugin, 0, 1)