func (pm *Manager) enable(p *v2.Plugin, force bool) error { if p.IsEnabled() && !force { return fmt.Errorf("plugin %s is already enabled", p.Name()) } spec, err := p.InitSpec(oci.DefaultSpec(), pm.libRoot) if err != nil { return err } p.Lock() p.Restart = true p.Unlock() if err := pm.containerdClient.Create(p.GetID(), "", "", specs.Spec(*spec)); err != nil { return err } p.PClient, err = plugins.NewClient("unix://"+filepath.Join(p.RuntimeSourcePath, p.GetSocket()), nil) if err != nil { p.Lock() p.Restart = false p.Unlock() return err } pm.pluginStore.SetState(p, true) pm.pluginStore.CallHandler(p) return nil }
func (pm *Manager) disable(p *v2.Plugin) error { if !p.IsEnabled() { return fmt.Errorf("plugin %s is already disabled", p.Name()) } p.Lock() p.Restart = false p.Unlock() shutdownPlugin(p, pm.containerdClient) pm.pluginStore.SetState(p, false) return nil }
func (pm *Manager) disable(p *v2.Plugin) error { if !p.IsEnabled() { return fmt.Errorf("plugin %s is already disabled", p.Name()) } p.Lock() p.Restart = false p.Unlock() if err := pm.containerdClient.Signal(p.GetID(), int(syscall.SIGKILL)); err != nil { logrus.Error(err) } pm.pluginStore.SetState(p, false) return nil }