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

fix: Reorder to skip observation collection #847

Merged
merged 1 commit into from
Oct 3, 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
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