-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/armadaproject/armada into…
… sched-more-it-rl
- Loading branch information
Showing
26 changed files
with
1,180 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package scheduling | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
armadaslices "github.com/armadaproject/armada/internal/common/slices" | ||
"github.com/armadaproject/armada/internal/scheduler/scheduling/context" | ||
"github.com/armadaproject/armada/internal/server/configuration" | ||
) | ||
|
||
const ( | ||
unknownPreemptionCause = "Preempted by scheduler due to the job failing to reschedule - possibly node resource changed causing this job to be unschedulable" | ||
unknownGangPreemptionCause = "Preempted by scheduler due to the job failing to reschedule - possibly another job in the gang was preempted or the node resource changed causing this job to be unschedulable" | ||
fairSharePreemptionTemplate = "Preempted by scheduler using fair share preemption - preempting job %s" | ||
urgencyPreemptionTemplate = "Preempted by scheduler using urgency preemption - preempting job %s" | ||
urgencyPreemptionMultiJobTemplate = "Preempted by scheduler using urgency preemption - preemption caused by one of the following jobs %s" | ||
) | ||
|
||
func PopulatePreemptionDescriptions(preemptedJobs []*context.JobSchedulingContext, scheduledJobs []*context.JobSchedulingContext) { | ||
jobsScheduledWithUrgencyBasedPreemptionByNode := map[string][]*context.JobSchedulingContext{} | ||
for _, schedJctx := range scheduledJobs { | ||
if schedJctx.PodSchedulingContext == nil { | ||
continue | ||
} | ||
if schedJctx.PodSchedulingContext.SchedulingMethod != context.ScheduledWithUrgencyBasedPreemption { | ||
continue | ||
} | ||
|
||
nodeId := schedJctx.PodSchedulingContext.NodeId | ||
if _, ok := jobsScheduledWithUrgencyBasedPreemptionByNode[nodeId]; !ok { | ||
jobsScheduledWithUrgencyBasedPreemptionByNode[nodeId] = []*context.JobSchedulingContext{} | ||
} | ||
jobsScheduledWithUrgencyBasedPreemptionByNode[nodeId] = append(jobsScheduledWithUrgencyBasedPreemptionByNode[nodeId], schedJctx) | ||
} | ||
|
||
for _, preemptedJctx := range preemptedJobs { | ||
if preemptedJctx.PreemptingJobId != "" { | ||
preemptedJctx.PreemptionDescription = fmt.Sprintf(fairSharePreemptionTemplate, preemptedJctx.PreemptingJobId) | ||
} else { | ||
potentialPreemptingJobs := jobsScheduledWithUrgencyBasedPreemptionByNode[preemptedJctx.GetAssignedNodeId()] | ||
|
||
if len(potentialPreemptingJobs) == 0 { | ||
_, isGang := preemptedJctx.Job.Annotations()[configuration.GangIdAnnotation] | ||
if isGang { | ||
preemptedJctx.PreemptionDescription = fmt.Sprintf(unknownGangPreemptionCause) | ||
} else { | ||
preemptedJctx.PreemptionDescription = fmt.Sprintf(unknownPreemptionCause) | ||
} | ||
} else if len(potentialPreemptingJobs) == 1 { | ||
preemptedJctx.PreemptionDescription = fmt.Sprintf(urgencyPreemptionTemplate, potentialPreemptingJobs[0].JobId) | ||
} else { | ||
jobIds := armadaslices.Map(potentialPreemptingJobs, func(job *context.JobSchedulingContext) string { | ||
return job.JobId | ||
}) | ||
preemptedJctx.PreemptionDescription = fmt.Sprintf(urgencyPreemptionMultiJobTemplate, strings.Join(jobIds, ",")) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.