Skip to content

Commit

Permalink
Remove useAdjustedFairShareProtection flag (#3806)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Martin <[email protected]>
Co-authored-by: Chris Martin <[email protected]>
  • Loading branch information
d80tb7 and d80tb7 authored Jul 22, 2024
1 parent 62302d9 commit f8013fc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 31 deletions.
1 change: 0 additions & 1 deletion config/scheduler/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ scheduling:
disableScheduling: false
enableAssertions: false
protectedFractionOfFairShare: 1.0
useAdjustedFairShareProtection: true
nodeIdLabel: "kubernetes.io/hostname"
priorityClasses:
armada-default:
Expand Down
2 changes: 0 additions & 2 deletions internal/scheduler/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ type SchedulingConfig struct {
EnableAssertions bool
// Only queues allocated more than this fraction of their fair share are considered for preemption.
ProtectedFractionOfFairShare float64 `validate:"gte=0"`
// Use Max(AdjustedFairShare, FairShare) for fair share protection. If false then FairShare will be used.
UseAdjustedFairShareProtection bool
// Armada adds a node selector term to every scheduled pod using this label with the node name as value.
// This to force kube-scheduler to schedule pods on the node chosen by Armada.
// For example, if NodeIdLabel is "kubernetes.io/hostname" and armada schedules a pod on node "myNode",
Expand Down
38 changes: 16 additions & 22 deletions internal/scheduler/preempting_queue_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ import (
// PreemptingQueueScheduler is a scheduler that makes a unified decisions on which jobs to preempt and schedule.
// Uses QueueScheduler as a building block.
type PreemptingQueueScheduler struct {
schedulingContext *schedulercontext.SchedulingContext
constraints schedulerconstraints.SchedulingConstraints
floatingResourceTypes *floatingresources.FloatingResourceTypes
protectedFractionOfFairShare float64
useAdjustedFairShareProtection bool
jobRepo JobRepository
nodeDb *nodedb.NodeDb
schedulingContext *schedulercontext.SchedulingContext
constraints schedulerconstraints.SchedulingConstraints
floatingResourceTypes *floatingresources.FloatingResourceTypes
protectedFractionOfFairShare float64
jobRepo JobRepository
nodeDb *nodedb.NodeDb
// Maps job ids to the id of the node the job is associated with.
// For scheduled or running jobs, that is the node the job is assigned to.
// For preempted jobs, that is the node the job was preempted from.
Expand All @@ -54,7 +53,6 @@ func NewPreemptingQueueScheduler(
constraints schedulerconstraints.SchedulingConstraints,
floatingResourceTypes *floatingresources.FloatingResourceTypes,
protectedFractionOfFairShare float64,
useAdjustedFairShareProtection bool,
jobRepo JobRepository,
nodeDb *nodedb.NodeDb,
initialNodeIdByJobId map[string]string,
Expand All @@ -75,16 +73,15 @@ func NewPreemptingQueueScheduler(
initialJobIdsByGangId[gangId] = maps.Clone(jobIds)
}
return &PreemptingQueueScheduler{
schedulingContext: sctx,
constraints: constraints,
floatingResourceTypes: floatingResourceTypes,
protectedFractionOfFairShare: protectedFractionOfFairShare,
useAdjustedFairShareProtection: useAdjustedFairShareProtection,
jobRepo: jobRepo,
nodeDb: nodeDb,
nodeIdByJobId: maps.Clone(initialNodeIdByJobId),
jobIdsByGangId: initialJobIdsByGangId,
gangIdByJobId: maps.Clone(initialGangIdByJobId),
schedulingContext: sctx,
constraints: constraints,
floatingResourceTypes: floatingResourceTypes,
protectedFractionOfFairShare: protectedFractionOfFairShare,
jobRepo: jobRepo,
nodeDb: nodeDb,
nodeIdByJobId: maps.Clone(initialNodeIdByJobId),
jobIdsByGangId: initialJobIdsByGangId,
gangIdByJobId: maps.Clone(initialGangIdByJobId),
}
}

Expand Down Expand Up @@ -136,10 +133,7 @@ func (sch *PreemptingQueueScheduler) Schedule(ctx *armadacontext.Context) (*Sche
}
if qctx, ok := sch.schedulingContext.QueueSchedulingContexts[job.Queue()]; ok {
actualShare := sch.schedulingContext.FairnessCostProvider.UnweightedCostFromQueue(qctx) / totalCost
fairShare := qctx.FairShare
if sch.useAdjustedFairShareProtection {
fairShare = math.Max(qctx.AdjustedFairShare, fairShare)
}
fairShare := math.Max(qctx.AdjustedFairShare, qctx.FairShare)
fractionOfFairShare := actualShare / fairShare
if fractionOfFairShare <= sch.protectedFractionOfFairShare {
return false
Expand Down
3 changes: 0 additions & 3 deletions internal/scheduler/preempting_queue_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,6 @@ func TestPreemptingQueueScheduler(t *testing.T) {
constraints,
testfixtures.TestEmptyFloatingResources,
tc.SchedulingConfig.ProtectedFractionOfFairShare,
tc.SchedulingConfig.UseAdjustedFairShareProtection,
NewSchedulerJobRepositoryAdapter(jobDbTxn),
nodeDb,
nodeIdByJobId,
Expand Down Expand Up @@ -2224,7 +2223,6 @@ func BenchmarkPreemptingQueueScheduler(b *testing.B) {
constraints,
testfixtures.TestEmptyFloatingResources,
tc.SchedulingConfig.ProtectedFractionOfFairShare,
tc.SchedulingConfig.UseAdjustedFairShareProtection,
NewSchedulerJobRepositoryAdapter(jobDbTxn),
nodeDb,
nil,
Expand Down Expand Up @@ -2286,7 +2284,6 @@ func BenchmarkPreemptingQueueScheduler(b *testing.B) {
constraints,
testfixtures.TestEmptyFloatingResources,
tc.SchedulingConfig.ProtectedFractionOfFairShare,
tc.SchedulingConfig.UseAdjustedFairShareProtection,
NewSchedulerJobRepositoryAdapter(jobDbTxn),
nodeDb,
nil,
Expand Down
1 change: 0 additions & 1 deletion internal/scheduler/scheduling_algo.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ func (l *FairSchedulingAlgo) schedulePool(
constraints,
l.floatingResourceTypes,
l.schedulingConfig.ProtectedFractionOfFairShare,
l.schedulingConfig.UseAdjustedFairShareProtection,
NewSchedulerJobRepositoryAdapter(fsctx.txn),
nodeDb,
fsctx.nodeIdByJobId,
Expand Down
1 change: 0 additions & 1 deletion internal/scheduler/simulator/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ func (s *Simulator) handleScheduleEvent(ctx *armadacontext.Context) error {
constraints,
nloatingResourceTypes,
s.schedulingConfig.ProtectedFractionOfFairShare,
s.schedulingConfig.UseAdjustedFairShareProtection,
scheduler.NewSchedulerJobRepositoryAdapter(txn),
nodeDb,
// TODO: Necessary to support partial eviction.
Expand Down
1 change: 0 additions & 1 deletion internal/scheduler/testfixtures/testfixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func TestSchedulingConfig() schedulerconfiguration.SchedulingConfig {
ExecutorTimeout: 15 * time.Minute,
MaxUnacknowledgedJobsPerExecutor: math.MaxInt,
SupportedResourceTypes: GetTestSupportedResourceTypes(),
UseAdjustedFairShareProtection: true,
}
}

Expand Down

0 comments on commit f8013fc

Please sign in to comment.