Skip to content

Commit

Permalink
append vm deletion check
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Mar 21, 2022
1 parent 9faf2a1 commit c15afc5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ func (c *Controller) handleDeletePod(pod *v1.Pod) error {
var keepIpCR bool
if ok, sts := isStatefulSetPod(pod); ok {
toDel := isStatefulSetPodToDel(c.config.KubeClient, pod, sts)
delete, err := appendCheckStatefulSetPodToDel(c, pod)
delete, err := appendCheckPodToDel(c, pod)
if pod.DeletionTimestamp != nil {
// triggered by delete event
if !(toDel || (delete && err == nil)) {
Expand All @@ -607,9 +607,14 @@ func (c *Controller) handleDeletePod(pod *v1.Pod) error {
}
isVmPod, vmName := isVmPod(pod)
if isVmPod && c.config.EnableKeepVmIP {
if !c.isVmPodToDel(pod, vmName) {
toDel := c.isVmPodToDel(pod, vmName)
delete, err := appendCheckPodToDel(c, pod)
if pod.DeletionTimestamp != nil {
// triggered by delete event
if !(toDel || (delete && err == nil)) {
return nil
}
klog.V(3).Infof("delete vm pod %s", podName)
return nil
}
}

Expand Down Expand Up @@ -1230,7 +1235,7 @@ func (c *Controller) deleteAttachmentNetWorkIP(pod *v1.Pod) error {
return nil
}

func appendCheckStatefulSetPodToDel(c *Controller, pod *v1.Pod) (bool, error) {
func appendCheckPodToDel(c *Controller, pod *v1.Pod) (bool, error) {
// subnet for ns has been changed, and statefulset pod's ip is not in the range of subnet's cidr anymore
podNs, err := c.namespacesLister.Get(pod.Namespace)
if err != nil {
Expand Down

0 comments on commit c15afc5

Please sign in to comment.