From 70b76266b586d193c333aa37dcda031f3d89f108 Mon Sep 17 00:00:00 2001 From: Anusha Ragunathan Date: Thu, 16 Mar 2017 15:17:11 -0700 Subject: [PATCH] Wait to unmount propagatedmount before marking plugin as disabled. TestPluginTrustedInstall revealed a race in the plugin shutdown logic, where the exit channel signal was sent even before the propagated mounts were unmounted. If the same plugin was enabled, it would try to setup propagated mounts *before* it was unmounted resulting in errors. This change fixes the behavior by waiting until the unmount completes on disable before marking the plugin as disabled. Signed-off-by: Anusha Ragunathan --- plugin/manager.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/plugin/manager.go b/plugin/manager.go index a3ee15146f..2228a1a1c2 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -131,15 +131,6 @@ func (pm *Manager) StateChanged(id string, e libcontainerd.StateInfo) error { return err } - pm.mu.RLock() - c := pm.cMap[p] - - if c.exitChan != nil { - close(c.exitChan) - } - restart := c.restart - pm.mu.RUnlock() - os.RemoveAll(filepath.Join(pm.config.ExecRoot, id)) if p.PropagatedMount != "" { @@ -152,6 +143,14 @@ func (pm *Manager) StateChanged(id string, e libcontainerd.StateInfo) error { } } + pm.mu.RLock() + c := pm.cMap[p] + if c.exitChan != nil { + close(c.exitChan) + } + restart := c.restart + pm.mu.RUnlock() + if restart { pm.enable(p, c, true) }