Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 3e83d09

Browse files
johnugeorgek8s-ci-robot
authored andcommitted
Avoiding unnecessary status update (#220)
* Compatible with upstream changes * Avoid unnecessary status update * Fix tests * Return nil if no update
1 parent 44b052f commit 3e83d09

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/controller.v1/pytorch/controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ package pytorch
1717

1818
import (
1919
"fmt"
20-
"reflect"
2120
"strings"
2221
"time"
2322

2423
kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned"
2524
log "github.com/sirupsen/logrus"
2625
"k8s.io/api/core/v1"
26+
apiequality "k8s.io/apimachinery/pkg/api/equality"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
"k8s.io/apimachinery/pkg/runtime/schema"
2929
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -430,7 +430,10 @@ func (pc *PyTorchController) reconcilePyTorchJobs(job *pyv1.PyTorchJob) error {
430430
job.Status.ReplicaStatuses[rtype].Active = 0
431431
}
432432
}
433-
return pc.updateStatusHandler(job)
433+
if !apiequality.Semantic.DeepEqual(*oldStatus, job.Status) {
434+
return pc.updateStatusHandler(job)
435+
}
436+
return nil
434437
}
435438

436439
if pc.Config.EnableGangScheduling {
@@ -465,7 +468,7 @@ func (pc *PyTorchController) reconcilePyTorchJobs(job *pyv1.PyTorchJob) error {
465468
}
466469

467470
// No need to update the job if the status hasn't changed since last time.
468-
if !reflect.DeepEqual(*oldStatus, job.Status) {
471+
if !apiequality.Semantic.DeepEqual(*oldStatus, job.Status) {
469472
return pc.updateStatusHandler(job)
470473
}
471474
return nil

0 commit comments

Comments
 (0)