Skip to content

Commit

Permalink
fix: pod get deleted between configure nb and patch pod
Browse files Browse the repository at this point in the history
Sometimes pod get deleted between configure nb and patch pod.
Then we need to recycle resources again.
  • Loading branch information
oilbeater committed May 28, 2020
1 parent 7d66433 commit f7fdd2d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ func (c *Controller) handleAddPod(key string) error {

if _, err := c.config.KubeClient.CoreV1().Pods(namespace).Patch(name, types.JSONPatchType, generatePatchPayload(pod.Annotations, op)); err != nil {
if k8serrors.IsNotFound(err) {
// Sometimes pod is deleted between kube-ovn configure ovn-nb and patch pod.
// Then we need to recycle the resource again.
c.deletePodQueue.AddRateLimited(key)
return nil
}
klog.Errorf("patch pod %s/%s failed %v", name, namespace, err)
Expand Down Expand Up @@ -459,6 +462,12 @@ func (c *Controller) handleUpdatePod(key string) error {

pod.Annotations[util.RoutedAnnotation] = "true"
if _, err := c.config.KubeClient.CoreV1().Pods(namespace).Patch(name, types.JSONPatchType, generatePatchPayload(pod.Annotations, "replace")); err != nil {
if k8serrors.IsNotFound(err) {
// Sometimes pod is deleted between kube-ovn configure ovn-nb and patch pod.
// Then we need to recycle the resource again.
c.deletePodQueue.AddRateLimited(key)
return nil
}
klog.Errorf("patch pod %s/%s failed %v", name, namespace, err)
return err
}
Expand Down

0 comments on commit f7fdd2d

Please sign in to comment.