Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip status update if no changes #969

Merged
merged 1 commit into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/controller.v1beta1/tensorflow/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package tensorflow

import (
"fmt"
"reflect"
"time"

kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned"
Expand Down Expand Up @@ -339,6 +340,8 @@ func (tc *TFController) reconcileTFJobs(tfjob *tfv1beta1.TFJob) error {
logger := tflogger.LoggerForJob(tfjob)
logger.Infof("Reconcile TFJobs %s", tfjob.Name)

oldStatus := tfjob.Status.DeepCopy()

pods, err := tc.GetPodsForJob(tfjob)

if err != nil {
Expand Down Expand Up @@ -404,8 +407,11 @@ func (tc *TFController) reconcileTFJobs(tfjob *tfv1beta1.TFJob) error {
}
}

// TODO(CPH): Add check here, no need to update the tfjob if the status hasn't changed since last time.
return tc.updateStatusHandler(tfjob)
// no need to update the tfjob if the status hasn't changed since last time.
if !reflect.DeepEqual(*oldStatus, tfjob.Status) {
return tc.updateStatusHandler(tfjob)
}
return nil
}

// satisfiedExpectations returns true if the required adds/dels for the given tfjob have been observed.
Expand Down
10 changes: 8 additions & 2 deletions pkg/controller.v1beta2/tensorflow/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package tensorflow

import (
"fmt"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -339,6 +340,8 @@ func (tc *TFController) reconcileTFJobs(tfjob *tfv1beta2.TFJob) error {
logger := tflogger.LoggerForJob(tfjob)
logger.Infof("Reconcile TFJobs %s", tfjob.Name)

oldStatus := tfjob.Status.DeepCopy()

pods, err := tc.GetPodsForJob(tfjob)

if err != nil {
Expand Down Expand Up @@ -455,8 +458,11 @@ func (tc *TFController) reconcileTFJobs(tfjob *tfv1beta2.TFJob) error {
}
}

// TODO(CPH): Add check here, no need to update the tfjob if the status hasn't changed since last time.
return tc.updateStatusHandler(tfjob)
// no need to update the tfjob if the status hasn't changed since last time.
if !reflect.DeepEqual(*oldStatus, tfjob.Status) {
return tc.updateStatusHandler(tfjob)
}
return nil
}

// satisfiedExpectations returns true if the required adds/dels for the given tfjob have been observed.
Expand Down