runservice: rename Run.RunTasks to Run.Tasks
This commit is contained in:
parent
68e95ad3be
commit
3928851c10
|
@ -134,7 +134,7 @@ func createRunResponse(r *rstypes.Run, rc *rstypes.RunConfig) *RunResponse {
|
||||||
run.CanRestartFromScratch, _ = r.CanRestartFromScratch()
|
run.CanRestartFromScratch, _ = r.CanRestartFromScratch()
|
||||||
run.CanRestartFromFailedTasks, _ = r.CanRestartFromFailedTasks()
|
run.CanRestartFromFailedTasks, _ = r.CanRestartFromFailedTasks()
|
||||||
|
|
||||||
for name, rt := range r.RunTasks {
|
for name, rt := range r.Tasks {
|
||||||
rct := rc.Tasks[rt.ID]
|
rct := rc.Tasks[rt.ID]
|
||||||
run.Tasks[name] = createRunResponseTask(r, rt, rct)
|
run.Tasks[name] = createRunResponseTask(r, rt, rct)
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ func (h *RuntaskHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
run := runResp.Run
|
run := runResp.Run
|
||||||
rc := runResp.RunConfig
|
rc := runResp.RunConfig
|
||||||
|
|
||||||
rt, ok := run.RunTasks[taskID]
|
rt, ok := run.Tasks[taskID]
|
||||||
if !ok {
|
if !ok {
|
||||||
httpError(w, util.NewErrNotFound(errors.Errorf("run %q task %q not found", runID, taskID)))
|
httpError(w, util.NewErrNotFound(errors.Errorf("run %q task %q not found", runID, taskID)))
|
||||||
return
|
return
|
||||||
|
|
|
@ -186,7 +186,7 @@ func (h *LogsHandler) readTaskLogs(ctx context.Context, runID, taskID string, se
|
||||||
return errors.Errorf("no such run with id: %s", runID), true
|
return errors.Errorf("no such run with id: %s", runID), true
|
||||||
}
|
}
|
||||||
|
|
||||||
task, ok := r.RunTasks[taskID]
|
task, ok := r.Tasks[taskID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.Errorf("no such task with ID %s in run %s", taskID, runID), true
|
return errors.Errorf("no such task with ID %s in run %s", taskID, runID), true
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ func recreateRun(uuid util.UUIDGenerator, run *types.Run, rc *types.RunConfig, n
|
||||||
// currently we only restart a run resetting al failed tasks
|
// currently we only restart a run resetting al failed tasks
|
||||||
recreatedRCTasks := map[string]struct{}{}
|
recreatedRCTasks := map[string]struct{}{}
|
||||||
|
|
||||||
for _, rt := range run.RunTasks {
|
for _, rt := range run.Tasks {
|
||||||
if req.FromStart || rt.Status != types.RunTaskStatusSuccess {
|
if req.FromStart || rt.Status != types.RunTaskStatusSuccess {
|
||||||
rct, ok := rc.Tasks[rt.ID]
|
rct, ok := rc.Tasks[rt.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -343,19 +343,19 @@ func recreateRun(uuid util.UUIDGenerator, run *types.Run, rc *types.RunConfig, n
|
||||||
|
|
||||||
// remove deleted tasks from run config
|
// remove deleted tasks from run config
|
||||||
tasksToDelete := []string{}
|
tasksToDelete := []string{}
|
||||||
for _, rt := range run.RunTasks {
|
for _, rt := range run.Tasks {
|
||||||
if _, ok := rc.Tasks[rt.ID]; !ok {
|
if _, ok := rc.Tasks[rt.ID]; !ok {
|
||||||
tasksToDelete = append(tasksToDelete, rt.ID)
|
tasksToDelete = append(tasksToDelete, rt.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, rtID := range tasksToDelete {
|
for _, rtID := range tasksToDelete {
|
||||||
delete(run.RunTasks, rtID)
|
delete(run.Tasks, rtID)
|
||||||
}
|
}
|
||||||
// create new tasks from runconfig
|
// create new tasks from runconfig
|
||||||
for _, rct := range rc.Tasks {
|
for _, rct := range rc.Tasks {
|
||||||
if _, ok := run.RunTasks[rct.ID]; !ok {
|
if _, ok := run.Tasks[rct.ID]; !ok {
|
||||||
nrt := genRunTask(rct)
|
nrt := genRunTask(rct)
|
||||||
run.RunTasks[nrt.ID] = nrt
|
run.Tasks[nrt.ID] = nrt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ func genRun(rc *types.RunConfig) *types.Run {
|
||||||
Annotations: rc.Annotations,
|
Annotations: rc.Annotations,
|
||||||
Phase: types.RunPhaseQueued,
|
Phase: types.RunPhaseQueued,
|
||||||
Result: types.RunResultUnknown,
|
Result: types.RunResultUnknown,
|
||||||
RunTasks: make(map[string]*types.RunTask),
|
Tasks: make(map[string]*types.RunTask),
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rc.SetupErrors) > 0 {
|
if len(rc.SetupErrors) > 0 {
|
||||||
|
@ -463,7 +463,7 @@ func genRun(rc *types.RunConfig) *types.Run {
|
||||||
|
|
||||||
for _, rct := range rc.Tasks {
|
for _, rct := range rc.Tasks {
|
||||||
rt := genRunTask(rct)
|
rt := genRunTask(rct)
|
||||||
r.RunTasks[rt.ID] = rt
|
r.Tasks[rt.ID] = rt
|
||||||
}
|
}
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
@ -487,7 +487,7 @@ func (s *CommandHandler) ApproveRunTask(ctx context.Context, req *RunTaskApprove
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
task, ok := r.RunTasks[req.TaskID]
|
task, ok := r.Tasks[req.TaskID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return util.NewErrBadRequest(errors.Errorf("run %q doesn't have task %q", r.ID, req.TaskID))
|
return util.NewErrBadRequest(errors.Errorf("run %q doesn't have task %q", r.ID, req.TaskID))
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,11 +201,11 @@ func TestRecreateRun(t *testing.T) {
|
||||||
rc: rc.DeepCopy(),
|
rc: rc.DeepCopy(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks[inuuid("task01")].Status = types.RunTaskStatusFailed
|
run.Tasks[inuuid("task01")].Status = types.RunTaskStatusFailed
|
||||||
run.RunTasks[inuuid("task02")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task02")].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks[inuuid("task03")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task03")].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks[inuuid("task04")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task04")].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks[inuuid("task05")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task05")].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
outrc: outrc.DeepCopy(),
|
outrc: outrc.DeepCopy(),
|
||||||
|
@ -217,11 +217,11 @@ func TestRecreateRun(t *testing.T) {
|
||||||
rc: rc.DeepCopy(),
|
rc: rc.DeepCopy(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks[inuuid("task01")].Status = types.RunTaskStatusFailed
|
run.Tasks[inuuid("task01")].Status = types.RunTaskStatusFailed
|
||||||
run.RunTasks[inuuid("task02")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task02")].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks[inuuid("task03")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task03")].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks[inuuid("task04")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task04")].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks[inuuid("task05")].Status = types.RunTaskStatusSuccess
|
run.Tasks[inuuid("task05")].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
// task01 and task02 recreated
|
// task01 and task02 recreated
|
||||||
|
@ -246,17 +246,17 @@ func TestRecreateRun(t *testing.T) {
|
||||||
outrun := outrun.DeepCopy()
|
outrun := outrun.DeepCopy()
|
||||||
nrun := run.DeepCopy()
|
nrun := run.DeepCopy()
|
||||||
nrun.ID = outuuid("new")
|
nrun.ID = outuuid("new")
|
||||||
nrun.RunTasks = map[string]*types.RunTask{
|
nrun.Tasks = map[string]*types.RunTask{
|
||||||
outuuid("task01"): outrun.RunTasks[outuuid("task01")],
|
outuuid("task01"): outrun.Tasks[outuuid("task01")],
|
||||||
outuuid("task02"): outrun.RunTasks[outuuid("task02")],
|
outuuid("task02"): outrun.Tasks[outuuid("task02")],
|
||||||
inuuid("task03"): run.RunTasks[inuuid("task03")],
|
inuuid("task03"): run.Tasks[inuuid("task03")],
|
||||||
inuuid("task04"): run.RunTasks[inuuid("task04")],
|
inuuid("task04"): run.Tasks[inuuid("task04")],
|
||||||
inuuid("task05"): run.RunTasks[inuuid("task05")],
|
inuuid("task05"): run.Tasks[inuuid("task05")],
|
||||||
}
|
}
|
||||||
|
|
||||||
nrun.RunTasks[inuuid("task03")].Status = types.RunTaskStatusSuccess
|
nrun.Tasks[inuuid("task03")].Status = types.RunTaskStatusSuccess
|
||||||
nrun.RunTasks[inuuid("task04")].Status = types.RunTaskStatusSuccess
|
nrun.Tasks[inuuid("task04")].Status = types.RunTaskStatusSuccess
|
||||||
nrun.RunTasks[inuuid("task05")].Status = types.RunTaskStatusSuccess
|
nrun.Tasks[inuuid("task05")].Status = types.RunTaskStatusSuccess
|
||||||
|
|
||||||
return nrun
|
return nrun
|
||||||
}(),
|
}(),
|
||||||
|
|
|
@ -95,7 +95,7 @@ func advanceRunTasks(ctx context.Context, r *types.Run, rc *types.RunConfig) err
|
||||||
log.Debugf("rc: %s", util.Dump(rc))
|
log.Debugf("rc: %s", util.Dump(rc))
|
||||||
|
|
||||||
// get tasks that can be executed
|
// get tasks that can be executed
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
if rt.Skip {
|
if rt.Skip {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ func advanceRunTasks(ctx context.Context, r *types.Run, rc *types.RunConfig) err
|
||||||
parents := runconfig.GetParents(rc.Tasks, rct)
|
parents := runconfig.GetParents(rc.Tasks, rct)
|
||||||
finishedParents := 0
|
finishedParents := 0
|
||||||
for _, p := range parents {
|
for _, p := range parents {
|
||||||
rp := r.RunTasks[p.ID]
|
rp := r.Tasks[p.ID]
|
||||||
if rp.Status.IsFinished() && rp.ArchivesFetchFinished() {
|
if rp.Status.IsFinished() && rp.ArchivesFetchFinished() {
|
||||||
finishedParents++
|
finishedParents++
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ func advanceRunTasks(ctx context.Context, r *types.Run, rc *types.RunConfig) err
|
||||||
if allParentsFinished {
|
if allParentsFinished {
|
||||||
for _, p := range parents {
|
for _, p := range parents {
|
||||||
matched := false
|
matched := false
|
||||||
rp := r.RunTasks[p.ID]
|
rp := r.Tasks[p.ID]
|
||||||
conds := runconfig.GetParentDependConditions(rct, p)
|
conds := runconfig.GetParentDependConditions(rct, p)
|
||||||
for _, cond := range conds {
|
for _, cond := range conds {
|
||||||
switch cond {
|
switch cond {
|
||||||
|
@ -166,7 +166,7 @@ func getTasksToRun(ctx context.Context, r *types.Run, rc *types.RunConfig) ([]*t
|
||||||
|
|
||||||
tasksToRun := []*types.RunTask{}
|
tasksToRun := []*types.RunTask{}
|
||||||
// get tasks that can be executed
|
// get tasks that can be executed
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
if rt.Skip {
|
if rt.Skip {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ func getTasksToRun(ctx context.Context, r *types.Run, rc *types.RunConfig) ([]*t
|
||||||
parents := runconfig.GetParents(rc.Tasks, rct)
|
parents := runconfig.GetParents(rc.Tasks, rct)
|
||||||
finishedParents := 0
|
finishedParents := 0
|
||||||
for _, p := range parents {
|
for _, p := range parents {
|
||||||
rp := r.RunTasks[p.ID]
|
rp := r.Tasks[p.ID]
|
||||||
if rp.Status.IsFinished() && rp.ArchivesFetchFinished() {
|
if rp.Status.IsFinished() && rp.ArchivesFetchFinished() {
|
||||||
finishedParents++
|
finishedParents++
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ func (s *Scheduler) genExecutorTask(ctx context.Context, r *types.Run, rt *types
|
||||||
log.Debugf("rctParent: %s", util.Dump(rctParent))
|
log.Debugf("rctParent: %s", util.Dump(rctParent))
|
||||||
log.Debugf("ws: %s", util.Dump(ws))
|
log.Debugf("ws: %s", util.Dump(ws))
|
||||||
archives := []types.WorkspaceArchive{}
|
archives := []types.WorkspaceArchive{}
|
||||||
for _, archiveStep := range r.RunTasks[rctParent.ID].WorkspaceArchives {
|
for _, archiveStep := range r.Tasks[rctParent.ID].WorkspaceArchives {
|
||||||
archives = append(archives, types.WorkspaceArchive{TaskID: rctParent.ID, Step: archiveStep})
|
archives = append(archives, types.WorkspaceArchive{TaskID: rctParent.ID, Step: archiveStep})
|
||||||
}
|
}
|
||||||
log.Debugf("archives: %v", util.Dump(archives))
|
log.Debugf("archives: %v", util.Dump(archives))
|
||||||
|
@ -471,7 +471,7 @@ func advanceRun(ctx context.Context, r *types.Run, rc *types.RunConfig, hasActiv
|
||||||
|
|
||||||
// fail run if a task is failed
|
// fail run if a task is failed
|
||||||
if !r.Result.IsSet() && r.Phase == types.RunPhaseRunning {
|
if !r.Result.IsSet() && r.Phase == types.RunPhaseRunning {
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
rct, ok := rc.Tasks[rt.ID]
|
rct, ok := rc.Tasks[rt.ID]
|
||||||
log.Debugf("rct: %s", util.Dump(rct))
|
log.Debugf("rct: %s", util.Dump(rct))
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -490,7 +490,7 @@ func advanceRun(ctx context.Context, r *types.Run, rc *types.RunConfig, hasActiv
|
||||||
// see if run could be marked as success
|
// see if run could be marked as success
|
||||||
if !r.Result.IsSet() && r.Phase == types.RunPhaseRunning {
|
if !r.Result.IsSet() && r.Phase == types.RunPhaseRunning {
|
||||||
finished := true
|
finished := true
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
if !rt.Status.IsFinished() {
|
if !rt.Status.IsFinished() {
|
||||||
finished = false
|
finished = false
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ func advanceRun(ctx context.Context, r *types.Run, rc *types.RunConfig, hasActiv
|
||||||
// the run phase as finished
|
// the run phase as finished
|
||||||
if r.Result.IsSet() {
|
if r.Result.IsSet() {
|
||||||
finished := true
|
finished := true
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
if !rt.Status.IsFinished() {
|
if !rt.Status.IsFinished() {
|
||||||
finished = false
|
finished = false
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ func advanceRun(ctx context.Context, r *types.Run, rc *types.RunConfig, hasActiv
|
||||||
// if the run is finished AND there're no executor tasks scheduled we can mark
|
// if the run is finished AND there're no executor tasks scheduled we can mark
|
||||||
// all not started runtasks' fetch phases (setup step, logs and archives) as finished
|
// all not started runtasks' fetch phases (setup step, logs and archives) as finished
|
||||||
if r.Phase.IsFinished() {
|
if r.Phase.IsFinished() {
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
log.Debugf("rt: %s", util.Dump(rt))
|
log.Debugf("rt: %s", util.Dump(rt))
|
||||||
if rt.Status == types.RunTaskStatusNotStarted {
|
if rt.Status == types.RunTaskStatusNotStarted {
|
||||||
rt.SetupStep.LogPhase = types.RunTaskFetchPhaseFinished
|
rt.SetupStep.LogPhase = types.RunTaskFetchPhaseFinished
|
||||||
|
@ -569,7 +569,7 @@ func (s *Scheduler) handleExecutorTaskUpdate(ctx context.Context, et *types.Exec
|
||||||
func (s *Scheduler) updateRunTaskStatus(ctx context.Context, et *types.ExecutorTask, r *types.Run) error {
|
func (s *Scheduler) updateRunTaskStatus(ctx context.Context, et *types.ExecutorTask, r *types.Run) error {
|
||||||
log.Debugf("et: %s", util.Dump(et))
|
log.Debugf("et: %s", util.Dump(et))
|
||||||
|
|
||||||
rt, ok := r.RunTasks[et.ID]
|
rt, ok := r.Tasks[et.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.Errorf("no such run task with id %s for run %s", et.ID, r.ID)
|
return errors.Errorf("no such run task with id %s for run %s", et.ID, r.ID)
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ func (s *Scheduler) finishSetupLogPhase(ctx context.Context, runID, runTaskID st
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rt, ok := r.RunTasks[runTaskID]
|
rt, ok := r.Tasks[runTaskID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.Errorf("no such task with ID %s in run %s", runTaskID, runID)
|
return errors.Errorf("no such task with ID %s in run %s", runTaskID, runID)
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ func (s *Scheduler) finishStepLogPhase(ctx context.Context, runID, runTaskID str
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rt, ok := r.RunTasks[runTaskID]
|
rt, ok := r.Tasks[runTaskID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.Errorf("no such task with ID %s in run %s", runTaskID, runID)
|
return errors.Errorf("no such task with ID %s in run %s", runTaskID, runID)
|
||||||
}
|
}
|
||||||
|
@ -902,7 +902,7 @@ func (s *Scheduler) finishArchivePhase(ctx context.Context, runID, runTaskID str
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rt, ok := r.RunTasks[runTaskID]
|
rt, ok := r.Tasks[runTaskID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.Errorf("no such task with ID %s in run %s", runTaskID, runID)
|
return errors.Errorf("no such task with ID %s in run %s", runTaskID, runID)
|
||||||
}
|
}
|
||||||
|
@ -1045,7 +1045,7 @@ func (s *Scheduler) fetcher(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
for _, r := range runs {
|
for _, r := range runs {
|
||||||
log.Debugf("r: %s", util.Dump(r))
|
log.Debugf("r: %s", util.Dump(r))
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
log.Debugf("rt: %s", util.Dump(rt))
|
log.Debugf("rt: %s", util.Dump(rt))
|
||||||
if rt.Status.IsFinished() {
|
if rt.Status.IsFinished() {
|
||||||
s.fetchTaskLogs(ctx, r.ID, rt)
|
s.fetchTaskLogs(ctx, r.ID, rt)
|
||||||
|
@ -1160,7 +1160,7 @@ func (s *Scheduler) finishedRunArchiver(ctx context.Context, r *types.Run) error
|
||||||
}
|
}
|
||||||
|
|
||||||
done := true
|
done := true
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
// check that all logs are fetched
|
// check that all logs are fetched
|
||||||
if !rt.LogsFetchFinished() {
|
if !rt.LogsFetchFinished() {
|
||||||
done = false
|
done = false
|
||||||
|
@ -1181,7 +1181,7 @@ func (s *Scheduler) finishedRunArchiver(ctx context.Context, r *types.Run) error
|
||||||
// remove it before since it contains the reference to the executor where we
|
// remove it before since it contains the reference to the executor where we
|
||||||
// should fetch the data
|
// should fetch the data
|
||||||
|
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
log.Infof("deleting executor task %s", rt.ID)
|
log.Infof("deleting executor task %s", rt.ID)
|
||||||
if err := store.DeleteExecutorTask(ctx, s.e, rt.ID); err != nil {
|
if err := store.DeleteExecutorTask(ctx, s.e, rt.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -93,7 +93,7 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
// (if the runconfig task as Skip == true). This must match the status
|
// (if the runconfig task as Skip == true). This must match the status
|
||||||
// generated by command.genRun()
|
// generated by command.genRun()
|
||||||
run := &types.Run{
|
run := &types.Run{
|
||||||
RunTasks: map[string]*types.RunTask{
|
Tasks: map[string]*types.RunTask{
|
||||||
"task01": &types.RunTask{
|
"task01": &types.RunTask{
|
||||||
ID: "task01",
|
ID: "task01",
|
||||||
Status: types.RunTaskStatusNotStarted,
|
Status: types.RunTaskStatusNotStarted,
|
||||||
|
@ -139,13 +139,13 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task01"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task01"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task01"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task01"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task02"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task02"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -159,15 +159,15 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task04"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task04"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task05"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task05"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -180,15 +180,15 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks["task05"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task05"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -201,15 +201,15 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks["task05"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task05"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -223,15 +223,15 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks["task05"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task05"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -245,14 +245,14 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -266,15 +266,15 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks["task05"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task05"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -289,15 +289,15 @@ func TestAdvanceRunTasks(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: func() *types.Run {
|
out: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task03"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task03"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task04"].Status = types.RunTaskStatusSuccess
|
run.Tasks["task04"].Status = types.RunTaskStatusSuccess
|
||||||
run.RunTasks["task05"].WaitingApproval = true
|
run.Tasks["task05"].WaitingApproval = true
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -386,7 +386,7 @@ func TestGetTasksToRun(t *testing.T) {
|
||||||
// (if the runconfig task as Skip == true). This must match the status
|
// (if the runconfig task as Skip == true). This must match the status
|
||||||
// generated by command.genRun()
|
// generated by command.genRun()
|
||||||
run := &types.Run{
|
run := &types.Run{
|
||||||
RunTasks: map[string]*types.RunTask{
|
Tasks: map[string]*types.RunTask{
|
||||||
"task01": &types.RunTask{
|
"task01": &types.RunTask{
|
||||||
ID: "task01",
|
ID: "task01",
|
||||||
Status: types.RunTaskStatusNotStarted,
|
Status: types.RunTaskStatusNotStarted,
|
||||||
|
@ -432,8 +432,8 @@ func TestGetTasksToRun(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task01"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task01"].Status = types.RunTaskStatusSkipped
|
||||||
run.RunTasks["task02"].Status = types.RunTaskStatusSkipped
|
run.Tasks["task02"].Status = types.RunTaskStatusSkipped
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: []string{"task03", "task04"},
|
out: []string{"task03", "task04"},
|
||||||
|
@ -457,7 +457,7 @@ func TestGetTasksToRun(t *testing.T) {
|
||||||
}(),
|
}(),
|
||||||
r: func() *types.Run {
|
r: func() *types.Run {
|
||||||
run := run.DeepCopy()
|
run := run.DeepCopy()
|
||||||
run.RunTasks["task01"].Approved = true
|
run.Tasks["task01"].Approved = true
|
||||||
return run
|
return run
|
||||||
}(),
|
}(),
|
||||||
out: []string{"task01", "task03", "task04"},
|
out: []string{"task01", "task03", "task04"},
|
||||||
|
|
|
@ -328,8 +328,8 @@ func GetExecutorTasksForRun(ctx context.Context, e *etcd.Store, runID string) ([
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rtIDs := make([]string, len(r.RunTasks))
|
rtIDs := make([]string, len(r.Tasks))
|
||||||
for rtID, _ := range r.RunTasks {
|
for rtID, _ := range r.Tasks {
|
||||||
rtIDs = append(rtIDs, rtID)
|
rtIDs = append(rtIDs, rtID)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ type Run struct {
|
||||||
// Stop is used to signal from the scheduler when the run must be stopped
|
// Stop is used to signal from the scheduler when the run must be stopped
|
||||||
Stop bool `json:"stop,omitempty"`
|
Stop bool `json:"stop,omitempty"`
|
||||||
|
|
||||||
RunTasks map[string]*RunTask `json:"run_tasks,omitempty"`
|
Tasks map[string]*RunTask `json:"tasks,omitempty"`
|
||||||
EnqueueTime *time.Time `json:"enqueue_time,omitempty"`
|
EnqueueTime *time.Time `json:"enqueue_time,omitempty"`
|
||||||
StartTime *time.Time `json:"start_time,omitempty"`
|
StartTime *time.Time `json:"start_time,omitempty"`
|
||||||
EndTime *time.Time `json:"end_time,omitempty"`
|
EndTime *time.Time `json:"end_time,omitempty"`
|
||||||
|
@ -141,7 +141,7 @@ func (r *Run) ChangePhase(phase RunPhase) {
|
||||||
|
|
||||||
func (r *Run) TasksWaitingApproval() []string {
|
func (r *Run) TasksWaitingApproval() []string {
|
||||||
runTasksIDs := []string{}
|
runTasksIDs := []string{}
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
if rt.WaitingApproval {
|
if rt.WaitingApproval {
|
||||||
runTasksIDs = append(runTasksIDs, rt.ID)
|
runTasksIDs = append(runTasksIDs, rt.ID)
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ func (r *Run) CanRestartFromFailedTasks() (bool, string) {
|
||||||
return false, fmt.Sprintf("run %q has success result, cannot restart from failed tasks", r.ID)
|
return false, fmt.Sprintf("run %q has success result, cannot restart from failed tasks", r.ID)
|
||||||
}
|
}
|
||||||
// can restart only if the successful tasks are fully archived
|
// can restart only if the successful tasks are fully archived
|
||||||
for _, rt := range r.RunTasks {
|
for _, rt := range r.Tasks {
|
||||||
if rt.Status == RunTaskStatusSuccess {
|
if rt.Status == RunTaskStatusSuccess {
|
||||||
if !rt.LogsFetchFinished() || !rt.ArchivesFetchFinished() {
|
if !rt.LogsFetchFinished() || !rt.ArchivesFetchFinished() {
|
||||||
return false, fmt.Sprintf("run %q task %q not fully archived", r.ID, rt.ID)
|
return false, fmt.Sprintf("run %q task %q not fully archived", r.ID, rt.ID)
|
||||||
|
|
Loading…
Reference in New Issue