Support disable plugins.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
aa49e704e2
commit
eee592c3ac
@ -140,10 +140,19 @@ func Register(r *Registration) {
|
|||||||
register.r = append(register.r, r)
|
register.r = append(register.r, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Graph returns an ordered list of registered plugins for initialization
|
// Graph returns an ordered list of registered plugins for initialization.
|
||||||
func Graph() (ordered []*Registration) {
|
// Plugins in disableList specified by id will be disabled.
|
||||||
|
func Graph(disableList []string) (ordered []*Registration) {
|
||||||
register.RLock()
|
register.RLock()
|
||||||
defer register.RUnlock()
|
defer register.RUnlock()
|
||||||
|
for _, d := range disableList {
|
||||||
|
for i, r := range register.r {
|
||||||
|
if r.ID == d {
|
||||||
|
register.r = append(register.r[:i], register.r[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
added := map[*Registration]bool{}
|
added := map[*Registration]bool{}
|
||||||
for _, r := range register.r {
|
for _, r := range register.r {
|
||||||
|
@ -18,6 +18,9 @@ type Config struct {
|
|||||||
Debug Debug `toml:"debug"`
|
Debug Debug `toml:"debug"`
|
||||||
// Metrics and monitoring settings
|
// Metrics and monitoring settings
|
||||||
Metrics MetricsConfig `toml:"metrics"`
|
Metrics MetricsConfig `toml:"metrics"`
|
||||||
|
// DisabledPlugins are IDs of plugins to disable. Disabled plugins won't be
|
||||||
|
// initialized and started.
|
||||||
|
DisabledPlugins []string `toml:"disabled_plugins"`
|
||||||
// Plugins provides plugin specific configuration for the initialization of a plugin
|
// Plugins provides plugin specific configuration for the initialization of a plugin
|
||||||
Plugins map[string]toml.Primitive `toml:"plugins"`
|
Plugins map[string]toml.Primitive `toml:"plugins"`
|
||||||
// OOMScore adjust the containerd's oom score
|
// OOMScore adjust the containerd's oom score
|
||||||
|
@ -242,7 +242,7 @@ func LoadPlugins(config *Config) ([]*plugin.Registration, error) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// return the ordered graph for plugins
|
// return the ordered graph for plugins
|
||||||
return plugin.Graph(), nil
|
return plugin.Graph(config.DisabledPlugins), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func trapClosedConnErr(err error) error {
|
func trapClosedConnErr(err error) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user