From 77056e89e4b2aa8fcfcd2cee6e3ee53759a8f24d Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Mon, 24 Aug 2020 10:50:12 +0800 Subject: [PATCH] Avoid the API call to update pod if nothing is changed Signed-off-by: Dave Chen --- pkg/scheduler/util/utils.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/scheduler/util/utils.go b/pkg/scheduler/util/utils.go index 05e822e67d9..a210a898c08 100644 --- a/pkg/scheduler/util/utils.go +++ b/pkg/scheduler/util/utils.go @@ -133,6 +133,11 @@ func PatchPod(cs kubernetes.Interface, old *v1.Pod, new *v1.Pod) error { if err != nil { 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") return err }