Skip to content

Commit

Permalink
add check for pod update process
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Mar 1, 2022
1 parent 7886467 commit 87bb7f1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/controller/inspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,27 @@ func (c *Controller) inspectPod() error {
for _, lsp := range lsps {
if portName == lsp {
isLspExist = true
break
}
}
if !isLspExist {
delete(pod.Annotations, fmt.Sprintf(util.AllocatedAnnotationTemplate, podNet.ProviderName))
delete(pod.Annotations, util.RoutedAnnotation)
delete(pod.Annotations, fmt.Sprintf(util.RoutedAnnotationTemplate, podNet.ProviderName))
if _, err := c.config.KubeClient.CoreV1().Pods(pod.Namespace).Patch(context.Background(), pod.Name, types.JSONPatchType, generatePatchPayload(pod.Annotations, "replace"), metav1.PatchOptions{}, ""); err != nil {
klog.Errorf("patch pod %s/%s failed %v during inspection", pod.Name, pod.Namespace, err)
return err
}
klog.V(5).Infof("finish remove annotation for %s", portName)
c.addPodQueue.Add(fmt.Sprintf("%s/%s", pod.Namespace, pod.Name))
break
} else {
if pod.Annotations[fmt.Sprintf(util.AllocatedAnnotationTemplate, podNet.ProviderName)] == "true" && pod.Spec.NodeName != "" {
if pod.Annotations[fmt.Sprintf(util.RoutedAnnotationTemplate, podNet.ProviderName)] != "true" {
klog.V(5).Infof("enqueue update pod %s/%s", pod.Namespace, pod.Name)
c.updatePodQueue.Add(fmt.Sprintf("%s/%s", pod.Namespace, pod.Name))
break
}
}
}
}
}
Expand Down

0 comments on commit 87bb7f1

Please sign in to comment.