-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [POC] Add a cause field to JobPreemptedEvent This will now be populated with a cause for the job to be preempted Allowing you to distinguish: - If this Preemption was caused by API request - If this Preemption was caused by Fair share preemption - and the preempting job id - If this Preemption was caused by Urgency based preemption - and the preempting job id(s) - We cannot always narrow this down to a single job, so it will be a comma separated list of job ids Signed-off-by: JamesMurkin <[email protected]> * Proto changes Signed-off-by: JamesMurkin <[email protected]> * Remove changes to loadtest.go Signed-off-by: JamesMurkin <[email protected]> * Fix proto Signed-off-by: JamesMurkin <[email protected]> * Fix proto Signed-off-by: JamesMurkin <[email protected]> * Fix proto Signed-off-by: JamesMurkin <[email protected]> * Generate proto Signed-off-by: JamesMurkin <[email protected]> * Merge Signed-off-by: JamesMurkin <[email protected]> * Fix common Signed-off-by: JamesMurkin <[email protected]> * Add tests Signed-off-by: JamesMurkin <[email protected]> * Add unit tests Signed-off-by: JamesMurkin <[email protected]> * Improve tests Signed-off-by: JamesMurkin <[email protected]> * Fix simulator Signed-off-by: JamesMurkin <[email protected]> * Undo unrelated change Signed-off-by: JamesMurkin <[email protected]> * Set PreemptingJobId Signed-off-by: JamesMurkin <[email protected]> --------- Signed-off-by: JamesMurkin <[email protected]>
- Loading branch information
1 parent
0f87b66
commit 4416515
Showing
26 changed files
with
1,178 additions
and
598 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.