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

Commit a335542

Browse files
committed
Merge pull request #101 from feiskyer/clearup-network
Clearup network for stopped Pods
2 parents e0df0ed + 9d0ffea commit a335542

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/kubelet/hyper/hyper.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ func (r *runtime) GarbageCollect(gcPolicy kubecontainer.ContainerGCPolicy) error
13881388

13891389
for _, pod := range podInfos {
13901390
// omit not managed pods
1391-
_, _, err := kubecontainer.ParsePodFullName(pod.PodName)
1391+
podName, podNamespace, err := kubecontainer.ParsePodFullName(pod.PodName)
13921392
if err != nil {
13931393
continue
13941394
}
@@ -1423,6 +1423,22 @@ func (r *runtime) GarbageCollect(gcPolicy kubecontainer.ContainerGCPolicy) error
14231423
glog.Warningf("Hyper GarbageCollect: remove pod %s failed, error: %s", pod.PodID, err)
14241424
return err
14251425
}
1426+
1427+
// KillPod is only called for running Pods, we should teardown network here for non-running Pods
1428+
err = r.networkPlugin.TearDownPod(podNamespace, podName, "", "hyper")
1429+
if err != nil {
1430+
glog.Warningf("Hyper: networkPlugin.TearDownPod failed, error: %v", err)
1431+
}
1432+
1433+
// Delete pod spec file
1434+
specFileName := path.Join(hyperPodSpecDir, pod.PodName)
1435+
_, err = os.Stat(specFileName)
1436+
if err == nil {
1437+
e := os.Remove(specFileName)
1438+
if e != nil {
1439+
glog.Warningf("Hyper: delete spec file for %s failed, error: %v", pod.PodName, e)
1440+
}
1441+
}
14261442
}
14271443
}
14281444

0 commit comments

Comments
 (0)