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

Commit 0f4d286

Browse files
committed
fix the issue of missing sandbox delete in pod remove function
Signed-off-by: fupan <[email protected]>
1 parent 29b7d94 commit 0f4d286

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

daemon/pod/decommission.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ func (p *XPod) ForceQuit() {
4949
}
5050

5151
func (p *XPod) Remove(force bool) error {
52+
var err error
5253

5354
if p.IsRunning() {
5455
if !force {
55-
err := fmt.Errorf("pod is running, cannot be removed")
56+
err = fmt.Errorf("pod is running, cannot be removed")
5657
p.Log(ERROR, err)
5758
return err
5859
}
@@ -66,6 +67,17 @@ func (p *XPod) Remove(force bool) error {
6667
p.resourceLock.Lock()
6768
defer p.resourceLock.Unlock()
6869

70+
p.Log(INFO, "removing sandbox")
71+
if p.sandbox != nil {
72+
err = p.sandbox.Delete()
73+
}else{
74+
_, err = vc.DeleteSandbox(p.globalSpec.Id)
75+
}
76+
77+
if err != nil {
78+
p.Log(ERROR, "remove sandbox failed: %v", err)
79+
}
80+
6981
p.Log(INFO, "removing pod")
7082
p.statusLock.Lock()
7183
p.status = S_POD_NONE

0 commit comments

Comments
 (0)