Skip to content

Commit

Permalink
fix: Reorder to skip observation collection
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege committed Oct 3, 2019
1 parent 7ade03b commit d937b16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/controller.v1alpha3/trial/trial_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,23 @@ func (r *ReconcileTrial) reconcileTrial(instance *trialsv1alpha3.Trial) error {
return err
}

//Job already exists
//TODO Can desired Spec differ from deployedSpec?
// Job already exists
// TODO Can desired Spec differ from deployedSpec?
if deployedJob != nil {
if err = r.UpdateTrialStatusObservation(instance, deployedJob); err != nil {
logger.Error(err, "Update trial status observation error")
return err
}

jobConditionType, err := r.GetDeployedJobStatus(deployedJob)
if err != nil {
logger.Error(err, "Get deployed status error")
return err
}

// Update trial observation when the job is succeeded.
if isTrialSucceeded(instance, *jobConditionType) {
if err = r.UpdateTrialStatusObservation(instance, deployedJob); err != nil {
logger.Error(err, "Update trial status observation error")
return err
}
}

// Update Trial job status only
// if job has succeded and if observation field is available.
// if job has failed
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller.v1alpha3/trial/trial_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/caicloud/nirvana/log"
commonv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/common/v1alpha3"
trialsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/trials/v1alpha3"
api_pb "github.com/kubeflow/katib/pkg/apis/manager/v1alpha3"
Expand Down Expand Up @@ -155,6 +156,14 @@ func isTrialComplete(instance *trialsv1alpha3.Trial, jobConditionType commonv1.J
return false
}

func isTrialSucceeded(instance *trialsv1alpha3.Trial, jobConditionType commonv1.JobConditionType) bool {
if jobConditionType == commonv1.JobSucceeded {
return true
}

return false
}

func getBestObjectiveMetricValue(metricLogs []*api_pb.MetricLog, objectiveType commonv1alpha3.ObjectiveType) *float64 {
metricLogSize := len(metricLogs)
if metricLogSize == 0 {
Expand Down

0 comments on commit d937b16

Please sign in to comment.