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}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
logrus.Debugf("plugin state changed %s %#v", id, e)
|
||||
|
||||
switch e.State {
|
||||
case libcontainerd.StateExit:
|
||||
var shutdown bool
|
||||
pm.RLock()
|
||||
shutdown = pm.shutdown
|
||||
pm.RUnlock()
|
||||
if shutdown {
|
||||
pm.RLock()
|
||||
p, idOk := pm.plugins[id]
|
||||
pm.RUnlock()
|
||||
if !idOk {
|
||||
return ErrNotFound(id)
|
||||
}
|
||||
if pm.shutdown == true {
|
||||
p.exitChan <- true
|
||||
close(p.exitChan)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -143,10 +143,12 @@ func (pm *Manager) disable(p *plugin) error {
|
|||
|
||||
// Shutdown stops all plugins and called during daemon shutdown.
|
||||
func (pm *Manager) Shutdown() {
|
||||
pm.Lock()
|
||||
pm.shutdown = true
|
||||
pm.Unlock()
|
||||
|
||||
pm.RLock()
|
||||
defer pm.RUnlock()
|
||||
|
||||
pm.shutdown = true
|
||||
for _, p := range pm.plugins {
|
||||
if pm.liveRestore && p.PluginObj.Active {
|
||||
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 {
|
||||
logrus.Errorf("Remove plugin runtime failed with error: %v", err)
|
||||
|
|
Loading…
Reference in a new issue