runservice: refactor fetch phase check
Use dedicated functions
This commit is contained in:
parent
7fa14c1b7a
commit
1657a35a6f
|
@ -1030,27 +1030,17 @@ 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 {
|
||||
// check that all archives are fetched
|
||||
if !rt.ArchivesFetchFinished() {
|
||||
done = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// check all archives are fetched
|
||||
for _, lp := range rt.WorkspaceArchivesPhase {
|
||||
if lp != types.RunTaskFetchPhaseFinished {
|
||||
done = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !done {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue