Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip ok pod #3090

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,15 @@ func (c *Controller) enqueueAddPod(obj interface{}) {
return
}

klog.V(3).Infof("enqueue add pod %s", key)
c.addOrUpdatePodQueue.Add(key)
exist, err := c.podNeedSync(p)
if err != nil {
klog.Errorf("invalid pod net: %v", err)
return
}
if exist {
klog.Infof("enqueue add pod %s", key)
c.addOrUpdatePodQueue.Add(key)
}
}

func (c *Controller) enqueueDeletePod(obj interface{}) {
Expand All @@ -239,7 +246,7 @@ func (c *Controller) enqueueDeletePod(obj interface{}) {
return
}

klog.V(3).Infof("enqueue delete pod %s", key)
klog.Infof("enqueue delete pod %s", key)
c.deletingPodObjMap.Store(key, p)
c.deletePodQueue.Add(key)
}
Expand Down Expand Up @@ -337,7 +344,7 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) {
}()
return
}

klog.Infof("enqueue update pod %s", key)
c.addOrUpdatePodQueue.Add(key)

// security policy changed
Expand Down Expand Up @@ -1210,6 +1217,28 @@ func needAllocateSubnets(pod *v1.Pod, nets []*kubeovnNet) []*kubeovnNet {
return result
}

func (c *Controller) podNeedSync(pod *v1.Pod) (bool, error) {
// 1. check annotations
if pod.Annotations == nil {
return true, nil
}
// 2. check annotation ovn subnet
if pod.Annotations[util.RoutedAnnotation] != "true" {
return true, nil
}
// 3. check multus subnet
attachmentNets, err := c.getPodAttachmentNet(pod)
if err != nil {
return false, err
}
for _, n := range attachmentNets {
if pod.Annotations[fmt.Sprintf(util.RoutedAnnotationTemplate, n.ProviderName)] != "true" {
return true, nil
}
}
return false, nil
}

func needRouteSubnets(pod *v1.Pod, nets []*kubeovnNet) []*kubeovnNet {
if !isPodAlive(pod) {
return nil
Expand Down
Loading