From 65bcf75d303969ae00045709209d154f4e298823 Mon Sep 17 00:00:00 2001 From: Yuki Iwai Date: Thu, 19 Jan 2023 22:59:40 +0900 Subject: [PATCH] Add the logic to check PodGroup changes Signed-off-by: Yuki Iwai --- pkg/controller.v1/common/scheduling.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/controller.v1/common/scheduling.go b/pkg/controller.v1/common/scheduling.go index 038ba73e..a6966ca5 100644 --- a/pkg/controller.v1/common/scheduling.go +++ b/pkg/controller.v1/common/scheduling.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + "github.com/google/go-cmp/cmp" apiv1 "github.com/kubeflow/common/pkg/apis/common/v1" @@ -41,10 +42,14 @@ func (jc *JobController) SyncPodGroup(job metav1.Object, specFunc FillPodGroupSp podGroup, err := pgctl.GetPodGroup(job.GetNamespace(), job.GetName()) if err == nil { // update podGroup for gang scheduling + oldPodGroup := podGroup if err = specFunc(podGroup); err != nil { return nil, fmt.Errorf("unable to fill the spec of PodGroup, '%v': %v", klog.KObj(podGroup), err) } - return nil, pgctl.UpdatePodGroup(podGroup.(client.Object)) + if diff := cmp.Diff(oldPodGroup, podGroup); len(diff) != 0 { + return podGroup, pgctl.UpdatePodGroup(podGroup.(client.Object)) + } + return podGroup, nil } else if client.IgnoreNotFound(err) != nil { return nil, fmt.Errorf("unable to get a PodGroup: %v", err) } else {