mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #94187 from chendave/avoid_apicall
Avoid the API call to update pod if nothing is changed
This commit is contained in:
commit
6b388f0684
@ -133,6 +133,11 @@ func PatchPod(cs kubernetes.Interface, old *v1.Pod, new *v1.Pod) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create merge patch for pod %q/%q: %v", old.Namespace, old.Name, err)
|
return fmt.Errorf("failed to create merge patch for pod %q/%q: %v", old.Namespace, old.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if "{}" == string(patchBytes) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
_, err = cs.CoreV1().Pods(old.Namespace).Patch(context.TODO(), old.Name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}, "status")
|
_, err = cs.CoreV1().Pods(old.Namespace).Patch(context.TODO(), old.Name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}, "status")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user