-
Notifications
You must be signed in to change notification settings - Fork 126
/
result.go
54 lines (49 loc) · 2.08 KB
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package scheduler
import (
schedulercontext "github.com/armadaproject/armada/internal/scheduler/context"
"github.com/armadaproject/armada/internal/scheduler/jobdb"
)
// SchedulerResult is returned by Rescheduler.Schedule().
type SchedulerResult struct {
// Running jobs that should be preempted.
PreemptedJobs []*schedulercontext.JobSchedulingContext
// Queued jobs that should be scheduled.
ScheduledJobs []*schedulercontext.JobSchedulingContext
// Queued jobs that could not be scheduled.
// This is used to fail jobs that could not schedule above `minimumGangCardinality`.
FailedJobs []*schedulercontext.JobSchedulingContext
// For each preempted job, maps the job id to the id of the node on which the job was running.
// For each scheduled job, maps the job id to the id of the node on which the job should be scheduled.
NodeIdByJobId map[string]string
// Each result may bundle the result of several scheduling decisions.
// These are the corresponding scheduling contexts.
// TODO: This doesn't seem like the right approach.
SchedulingContexts []*schedulercontext.SchedulingContext
// Additional annotations to be appended to the PodSpec.
// Format: JobId -> AnnotationName -> AnnotationValue.
AdditionalAnnotationsByJobId map[string]map[string]string
}
// PreemptedJobsFromSchedulerResult returns the slice of preempted jobs in the result.
func PreemptedJobsFromSchedulerResult(sr *SchedulerResult) []*jobdb.Job {
rv := make([]*jobdb.Job, len(sr.PreemptedJobs))
for i, jctx := range sr.PreemptedJobs {
rv[i] = jctx.Job
}
return rv
}
// ScheduledJobsFromSchedulerResult returns the slice of scheduled jobs in the result.
func ScheduledJobsFromSchedulerResult(sr *SchedulerResult) []*jobdb.Job {
rv := make([]*jobdb.Job, len(sr.ScheduledJobs))
for i, jctx := range sr.ScheduledJobs {
rv[i] = jctx.Job
}
return rv
}
// FailedJobsFromSchedulerResult returns the slice of scheduled jobs in the result.
func FailedJobsFromSchedulerResult(sr *SchedulerResult) []*jobdb.Job {
rv := make([]*jobdb.Job, len(sr.FailedJobs))
for i, jctx := range sr.FailedJobs {
rv[i] = jctx.Job
}
return rv
}