Skip to content

Commit

Permalink
fix: Reorder
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 cac3910
Show file tree
Hide file tree
Showing 2 changed files with 19 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
8 changes: 8 additions & 0 deletions pkg/controller.v1alpha3/trial/trial_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,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 cac3910

Please sign in to comment.