Skip to content

Commit

Permalink
Distinguish between Preemption due to reclamation and fair sharing
Browse files Browse the repository at this point in the history
* Naive approach
  • Loading branch information
vladikkuzn committed Jun 14, 2024
1 parent 8b217c6 commit 45eee46
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions pkg/scheduler/preemption/preemption.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ func canBorrowWithinCohort(cq *cache.ClusterQueue, wl *kueue.Workload) (bool, *i
return true, &threshold
}

const (
// ClusterQueueOrigin indicates that preemption originated from cluster queue
ClusterQueueOrigin = "ClusterQueue"
// CohortOrigin indicates that preemption originated from cohort
CohortOrigin = "cohort"

InClusterQueueReason = "InClusterQueue"
InCohortReason = "InCohort"

InCohortReclamationReason = "InCohortReclamation"
InCohortFairSharingReason = "InCohortFairSharing"
)

// IssuePreemptions marks the target workloads as evicted.
func (p *Preemptor) IssuePreemptions(ctx context.Context, preemptor *workload.Info, targets []*workload.Info, cq *cache.ClusterQueue) (int, error) {
log := ctrl.LoggerFrom(ctx)
Expand All @@ -172,11 +185,15 @@ func (p *Preemptor) IssuePreemptions(ctx context.Context, preemptor *workload.In
workqueue.ParallelizeUntil(ctx, parallelPreemptions, len(targets), func(i int) {
target := targets[i]
if !meta.IsStatusConditionTrue(target.Obj.Status.Conditions, kueue.WorkloadEvicted) {
origin := "ClusterQueue"
reason := "InClusterQueue"
origin := ClusterQueueOrigin
reason := InClusterQueueReason
if cq.Name != target.ClusterQueue {
origin = "cohort"
reason = "InCohort"
origin = CohortOrigin
if p.enableFairSharing {
reason = InCohortFairSharingReason
} else {
reason = InCohortReclamationReason
}
}

message := fmt.Sprintf("Preempted to accommodate a workload (UID: %s) in the %s", preemptor.Obj.UID, origin)
Expand Down

0 comments on commit 45eee46

Please sign in to comment.