Skip to content

Commit

Permalink
fix: ippool pod static route might lost during leader election
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Oct 31, 2019
1 parent 925d6cd commit b9108fb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,16 @@ func (c *Controller) handleAddIpPoolPod(key string) error {

raw, _ := json.Marshal(pod.Annotations)
patchPayload := fmt.Sprintf(patchPayloadTemplate, op, raw)
_, err = c.config.KubeClient.CoreV1().Pods(namespace).Patch(name, types.JSONPatchType, []byte(patchPayload))
if err != nil {
if _, err = c.config.KubeClient.CoreV1().Pods(namespace).Patch(name, types.JSONPatchType, []byte(patchPayload)); err != nil {
klog.Errorf("patch pod %s/%s failed %v", name, namespace, err)
return err
}
return err

// In case update event might lost during leader election
if pod.Spec.NodeName != "" {
return c.handleUpdatePod(key)
}
return nil
}

func (c *Controller) handleDeletePod(key string) error {
Expand Down

0 comments on commit b9108fb

Please sign in to comment.