From 57d713a365d917e31868c352a4e4dc966eddd29b Mon Sep 17 00:00:00 2001 From: fupan Date: Fri, 22 Jun 2018 10:56:37 +0800 Subject: [PATCH] cleanup the sandbox after it exited Signed-off-by: fupan --- daemon/pod/decommission.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/daemon/pod/decommission.go b/daemon/pod/decommission.go index 33055da2..a805c1ae 100644 --- a/daemon/pod/decommission.go +++ b/daemon/pod/decommission.go @@ -49,10 +49,11 @@ func (p *XPod) ForceQuit() { } func (p *XPod) Remove(force bool) error { + var err error if p.IsRunning() { if !force { - err := fmt.Errorf("pod is running, cannot be removed") + err = fmt.Errorf("pod is running, cannot be removed") p.Log(ERROR, err) return err } @@ -624,6 +625,11 @@ func (p *XPod) decommissionResources() (err error) { } } + err = p.sandbox.Delete() + if err != nil { + p.Log(ERROR, "remove sandbox failed: %v", err) + } + p.sandbox = nil cleanupHosts(p.Id())