Merge pull request #25723 from anusha-ragunathan/plugin-force-rm
When handling plugin exit, lookup plugins only during daemon shutdown.
This commit is contained in:
commit
70f843f7ae
2 changed files with 15 additions and 10 deletions
|
@ -253,20 +253,24 @@ func LookupWithCapability(name, capability string) (Plugin, error) {
|
||||||
return nil, ErrInadequateCapability{name, capability}
|
return nil, ErrInadequateCapability{name, capability}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateChanged updates plugin internals using from libcontainerd events.
|
// StateChanged updates plugin internals using libcontainerd events.
|
||||||
func (pm *Manager) StateChanged(id string, e libcontainerd.StateInfo) error {
|
func (pm *Manager) StateChanged(id string, e libcontainerd.StateInfo) error {
|
||||||
logrus.Debugf("plugin state changed %s %#v", id, e)
|
logrus.Debugf("plugin state changed %s %#v", id, e)
|
||||||
|
|
||||||
switch e.State {
|
switch e.State {
|
||||||
case libcontainerd.StateExit:
|
case libcontainerd.StateExit:
|
||||||
|
var shutdown bool
|
||||||
pm.RLock()
|
pm.RLock()
|
||||||
p, idOk := pm.plugins[id]
|
shutdown = pm.shutdown
|
||||||
pm.RUnlock()
|
pm.RUnlock()
|
||||||
if !idOk {
|
if shutdown {
|
||||||
return ErrNotFound(id)
|
pm.RLock()
|
||||||
}
|
p, idOk := pm.plugins[id]
|
||||||
if pm.shutdown == true {
|
pm.RUnlock()
|
||||||
p.exitChan <- true
|
if !idOk {
|
||||||
|
return ErrNotFound(id)
|
||||||
|
}
|
||||||
|
close(p.exitChan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,10 +143,12 @@ func (pm *Manager) disable(p *plugin) error {
|
||||||
|
|
||||||
// Shutdown stops all plugins and called during daemon shutdown.
|
// Shutdown stops all plugins and called during daemon shutdown.
|
||||||
func (pm *Manager) Shutdown() {
|
func (pm *Manager) Shutdown() {
|
||||||
|
pm.Lock()
|
||||||
|
pm.shutdown = true
|
||||||
|
pm.Unlock()
|
||||||
|
|
||||||
pm.RLock()
|
pm.RLock()
|
||||||
defer pm.RUnlock()
|
defer pm.RUnlock()
|
||||||
|
|
||||||
pm.shutdown = true
|
|
||||||
for _, p := range pm.plugins {
|
for _, p := range pm.plugins {
|
||||||
if pm.liveRestore && p.PluginObj.Active {
|
if pm.liveRestore && p.PluginObj.Active {
|
||||||
logrus.Debug("Plugin active when liveRestore is set, skipping shutdown")
|
logrus.Debug("Plugin active when liveRestore is set, skipping shutdown")
|
||||||
|
@ -173,7 +175,6 @@ func (pm *Manager) Shutdown() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(p.exitChan)
|
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(p.runtimeSourcePath); err != nil {
|
if err := os.RemoveAll(p.runtimeSourcePath); err != nil {
|
||||||
logrus.Errorf("Remove plugin runtime failed with error: %v", err)
|
logrus.Errorf("Remove plugin runtime failed with error: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue