Skip to content

Commit

Permalink
fix: error log found in scale test
Browse files Browse the repository at this point in the history
1. Move enqueue updatePodQueue from handleAddPod to enqueueAddPod
2. When podip not ready do not try to add it to ipset
  • Loading branch information
oilbeater committed Apr 29, 2020
1 parent 6a7ca58 commit 0dc7676
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 13 additions & 8 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ func (c *Controller) enqueueAddPod(obj interface{}) {
return
}

// In case update event might lost during leader election
if p.Annotations != nil &&
p.Annotations[util.AllocatedAnnotation] == "true" &&
p.Annotations[util.RoutedAnnotation] != "true" &&
p.Status.HostIP != "" && p.Status.PodIP != "" {
c.updatePodQueue.Add(key)
return
}

if p.Annotations != nil && p.Annotations[util.AllocatedAnnotation] == "true" {
return
}

klog.V(3).Infof("enqueue add pod %s", key)
c.addPodQueue.Add(key)
}
Expand Down Expand Up @@ -366,14 +379,6 @@ func (c *Controller) handleAddPod(key string) error {
klog.Errorf("patch pod %s/%s failed %v", name, namespace, err)
return err
}

// In case update event might lost during leader election
if pod.Annotations[util.AllocatedAnnotation] == "true" &&
pod.Annotations[util.RoutedAnnotation] != "true" &&
pod.Spec.NodeName != "" {
c.updatePodQueue.Add(key)
}

return nil
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/daemon/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ func (c *Controller) getLocalPodIPsNeedNAT(protocol string) ([]string, error) {
return nil, err
}
for _, pod := range allPods {
if pod.Spec.HostNetwork == true || pod.Status.PodIP == "" {
if pod.Spec.HostNetwork == true ||
pod.Status.PodIP == "" ||
pod.Annotations[util.LogicalSwitchAnnotation] == "" {
continue
}
subnet, err := c.subnetsLister.Get(pod.Annotations[util.LogicalSwitchAnnotation])
Expand Down

0 comments on commit 0dc7676

Please sign in to comment.