Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Commit

Permalink
fix the issue of missing sandbox delete in pod remove function
Browse files Browse the repository at this point in the history
Signed-off-by: fupan <[email protected]>
  • Loading branch information
lifupan committed Jun 22, 2018
1 parent 29b7d94 commit 0f4d286
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion daemon/pod/decommission.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -66,6 +67,17 @@ func (p *XPod) Remove(force bool) error {
p.resourceLock.Lock()
defer p.resourceLock.Unlock()

p.Log(INFO, "removing sandbox")
if p.sandbox != nil {
err = p.sandbox.Delete()
}else{
_, err = vc.DeleteSandbox(p.globalSpec.Id)
}

if err != nil {
p.Log(ERROR, "remove sandbox failed: %v", err)
}

p.Log(INFO, "removing pod")
p.statusLock.Lock()
p.status = S_POD_NONE
Expand Down

0 comments on commit 0f4d286

Please sign in to comment.