| @@ -296,6 +296,23 @@ func queryTaskStatusFromCloudbrainTwo(job *models.Cloudbrain) { | |||||
| } | } | ||||
| func updateCloudBrainOneJobTime(task *models.Cloudbrain) { | |||||
| if task.TrainJobDuration == "" { | |||||
| if task.Duration == 0 { | |||||
| var duration int64 | |||||
| if task.Status == string(models.JobWaiting) { | |||||
| duration = 0 | |||||
| } else if task.Status == string(models.JobRunning) { | |||||
| duration = time.Now().Unix() - int64(task.CreatedUnix) | |||||
| } else { | |||||
| duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) | |||||
| } | |||||
| task.Duration = duration | |||||
| } | |||||
| task.TrainJobDuration = models.ConvertDurationToStr(task.Duration) | |||||
| } | |||||
| } | |||||
| func queryTaskStatusFromCloudbrain(job *models.Cloudbrain) { | func queryTaskStatusFromCloudbrain(job *models.Cloudbrain) { | ||||
| log.Info("The task not finished,name=" + job.DisplayJobName) | log.Info("The task not finished,name=" + job.DisplayJobName) | ||||
| @@ -312,6 +329,7 @@ func queryTaskStatusFromCloudbrain(job *models.Cloudbrain) { | |||||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | ||||
| job.Status = taskRes.TaskStatuses[0].State | job.Status = taskRes.TaskStatuses[0].State | ||||
| } | } | ||||
| updateCloudBrainOneJobTime(job) | |||||
| log.Info("cloud brain one job status=" + job.Status) | log.Info("cloud brain one job status=" + job.Status) | ||||
| if result.JobStatus.State != string(models.JobSucceeded) { | if result.JobStatus.State != string(models.JobSucceeded) { | ||||
| err = models.UpdateJob(job) | err = models.UpdateJob(job) | ||||