Update the job ID in flow controller

Update the job ID for the task if it is scheduled successfully

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin 2019-03-12 15:42:16 +08:00
parent 27b65f4739
commit 7ab21db26a
2 changed files with 5 additions and 3 deletions

View File

@ -246,12 +246,13 @@ func (f *flow) schedule() error {
continue
}
allFailed = false
// if the task is submitted successfully, update the status and start time
// if the task is submitted successfully, update the status, job ID and start time
if err = f.executionMgr.UpdateTaskStatus(result.TaskID, model.TaskStatusPending); err != nil {
log.Errorf("failed to update task status %d: %v", result.TaskID, err)
}
if err = f.executionMgr.UpdateTask(&model.Task{
ID: result.TaskID,
JobID: result.JobID,
StartTime: time.Now(),
}); err != nil {
log.Errorf("failed to update task %d: %v", result.TaskID, err)

View File

@ -49,6 +49,7 @@ type ScheduleItem struct {
// ScheduleResult is the result of the schedule for one item
type ScheduleResult struct {
TaskID int64
JobID string
Error error
}
@ -119,16 +120,16 @@ func (d *DefaultReplicator) Schedule(items []*ScheduleItem) ([]*ScheduleResult,
"src_resource": string(src),
"dst_resource": string(dest),
}
_, joberr := d.client.SubmitJob(job)
id, joberr := d.client.SubmitJob(job)
if joberr != nil {
result.Error = joberr
results = append(results, result)
continue
}
result.JobID = id
results = append(results, result)
}
return results, nil
}
// Stop the transfer job