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 1953712 commit 2419050
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,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 @@ -632,6 +632,18 @@ func (c *Controller) handleDeletePod(pod *v1.Pod) error {
}
keepIpCR = !toDel && !delete && err == nil
}
isVmPod, vmName := isVmPod(pod)
if isVmPod && c.config.EnableKeepVmIP {
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)
}
}

// Add additional default ports to compatible with previous versions
ports = append(ports, ovs.PodNameToPortName(podName, pod.Namespace, util.OvnProvider))
Expand Down Expand Up @@ -1269,7 +1281,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 2419050

Please sign in to comment.