runservice: refactor fetch phase check

Use dedicated functions
This commit is contained in:
Simone Gotti 2019-03-29 09:00:19 +01:00
parent 7fa14c1b7a
commit 1657a35a6f
2 changed files with 20 additions and 17 deletions

View File

@ -1030,25 +1030,15 @@ func (s *Scheduler) finishedRunArchiver(ctx context.Context, r *types.Run) error
done := true
for _, rt := range r.RunTasks {
// check all logs are fetched
if rt.SetupStep.LogPhase != types.RunTaskFetchPhaseFinished {
// check that all logs are fetched
if !rt.LogsFetchFinished() {
done = false
break
}
for _, rts := range rt.Steps {
lp := rts.LogPhase
if lp != types.RunTaskFetchPhaseFinished {
done = false
break
}
}
// check all archives are fetched
for _, lp := range rt.WorkspaceArchivesPhase {
if lp != types.RunTaskFetchPhaseFinished {
done = false
break
}
// check that all archives are fetched
if !rt.ArchivesFetchFinished() {
done = false
break
}
}
if !done {

View File

@ -184,9 +184,22 @@ type RunTask struct {
EndTime *time.Time `json:"end_time,omitempty"`
}
func (rt *RunTask) LogsFetchFinished() bool {
if rt.SetupStep.LogPhase != RunTaskFetchPhaseFinished {
return false
}
for _, rts := range rt.Steps {
lp := rts.LogPhase
if lp != RunTaskFetchPhaseFinished {
return false
}
}
return true
}
func (rt *RunTask) ArchivesFetchFinished() bool {
for _, p := range rt.WorkspaceArchivesPhase {
if p == RunTaskFetchPhaseNotStarted {
if p != RunTaskFetchPhaseFinished {
return false
}
}