Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove some unused/unneeded fields from schedulingcontext #3964

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions internal/scheduler/scheduling/context/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
// QueueSchedulingContext captures the decisions made by the scheduler during one invocation
// for a particular queue.
type QueueSchedulingContext struct {
// The scheduling context to which this QueueSchedulingContext belongs.
SchedulingContext *SchedulingContext
// Time at which this context was created.
Created time.Time
// Queue name.
Expand Down
31 changes: 11 additions & 20 deletions internal/scheduler/scheduling/context/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ type SchedulingContext struct {
// Allocated resources across all clusters in this pool
Allocated schedulerobjects.ResourceList
// Resources assigned across all queues during this scheduling cycle.
ScheduledResources schedulerobjects.ResourceList
ScheduledResourcesByPriorityClass schedulerobjects.QuantityByTAndResourceType[string]
ScheduledResources schedulerobjects.ResourceList
// Resources evicted across all queues during this scheduling cycle.
EvictedResources schedulerobjects.ResourceList
EvictedResourcesByPriorityClass schedulerobjects.QuantityByTAndResourceType[string]
Expand All @@ -52,9 +51,6 @@ type SchedulingContext struct {
NumScheduledGangs int
// Total number of evicted jobs.
NumEvictedJobs int
// TODO(reports): Count the number of evicted gangs.
// Reason for why the scheduling round finished.
TerminationReason string
// Used to efficiently generate scheduling keys.
SchedulingKeyGenerator *schedulerobjects.SchedulingKeyGenerator
// Record of job scheduling requirements known to be unfeasible.
Expand All @@ -70,17 +66,16 @@ func NewSchedulingContext(
totalResources schedulerobjects.ResourceList,
) *SchedulingContext {
return &SchedulingContext{
Started: time.Now(),
Pool: pool,
FairnessCostProvider: fairnessCostProvider,
Limiter: limiter,
QueueSchedulingContexts: make(map[string]*QueueSchedulingContext),
TotalResources: totalResources.DeepCopy(),
ScheduledResources: schedulerobjects.NewResourceListWithDefaultSize(),
ScheduledResourcesByPriorityClass: make(schedulerobjects.QuantityByTAndResourceType[string]),
EvictedResourcesByPriorityClass: make(schedulerobjects.QuantityByTAndResourceType[string]),
SchedulingKeyGenerator: schedulerobjects.NewSchedulingKeyGenerator(),
UnfeasibleSchedulingKeys: make(map[schedulerobjects.SchedulingKey]*JobSchedulingContext),
Started: time.Now(),
Pool: pool,
FairnessCostProvider: fairnessCostProvider,
Limiter: limiter,
QueueSchedulingContexts: make(map[string]*QueueSchedulingContext),
TotalResources: totalResources.DeepCopy(),
ScheduledResources: schedulerobjects.NewResourceListWithDefaultSize(),
EvictedResourcesByPriorityClass: make(schedulerobjects.QuantityByTAndResourceType[string]),
SchedulingKeyGenerator: schedulerobjects.NewSchedulingKeyGenerator(),
UnfeasibleSchedulingKeys: make(map[schedulerobjects.SchedulingKey]*JobSchedulingContext),
}
}

Expand Down Expand Up @@ -115,7 +110,6 @@ func (sctx *SchedulingContext) AddQueueSchedulingContext(
sctx.Allocated.Add(allocated)

qctx := &QueueSchedulingContext{
SchedulingContext: sctx,
Created: time.Now(),
Queue: queue,
Weight: weight,
Expand Down Expand Up @@ -217,7 +211,6 @@ func (sctx *SchedulingContext) ReportString(verbosity int32) string {
fmt.Fprintf(w, "Started:\t%s\n", sctx.Started)
fmt.Fprintf(w, "Finished:\t%s\n", sctx.Finished)
fmt.Fprintf(w, "Duration:\t%s\n", sctx.Finished.Sub(sctx.Started))
fmt.Fprintf(w, "Termination reason:\t%s\n", sctx.TerminationReason)
fmt.Fprintf(w, "Total capacity:\t%s\n", sctx.TotalResources.CompactString())
fmt.Fprintf(w, "Scheduled resources:\t%s\n", sctx.ScheduledResources.CompactString())
fmt.Fprintf(w, "Preempted resources:\t%s\n", sctx.EvictedResources.CompactString())
Expand Down Expand Up @@ -293,7 +286,6 @@ func (sctx *SchedulingContext) AddJobSchedulingContext(jctx *JobSchedulingContex
sctx.NumEvictedJobs--
} else {
sctx.ScheduledResources.AddV1ResourceList(jctx.PodRequirements.ResourceRequirements.Requests)
sctx.ScheduledResourcesByPriorityClass.AddV1ResourceList(jctx.Job.PriorityClassName(), jctx.PodRequirements.ResourceRequirements.Requests)
sctx.NumScheduledJobs++
}
sctx.Allocated.AddV1ResourceList(jctx.PodRequirements.ResourceRequirements.Requests)
Expand Down Expand Up @@ -328,7 +320,6 @@ func (sctx *SchedulingContext) EvictJob(job *jobdb.Job) (bool, error) {
rl := job.ResourceRequirements().Requests
if scheduledInThisRound {
sctx.ScheduledResources.SubV1ResourceList(rl)
sctx.ScheduledResourcesByPriorityClass.SubV1ResourceList(job.PriorityClassName(), rl)
sctx.NumScheduledJobs--
} else {
sctx.EvictedResources.AddV1ResourceList(rl)
Expand Down
6 changes: 0 additions & 6 deletions internal/scheduler/scheduling/queue_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func (sch *QueueScheduler) Schedule(ctx *armadacontext.Context) (*SchedulerResul
// Calling Clear() after (failing to) schedule ensures we get the next gang in order of smallest fair share.
gctx, queueCostInclGang, err := sch.candidateGangIterator.Peek()
if err != nil {
sch.schedulingContext.TerminationReason = err.Error()
return nil, err
}
if gctx == nil {
Expand All @@ -102,7 +101,6 @@ func (sch *QueueScheduler) Schedule(ctx *armadacontext.Context) (*SchedulerResul
case <-ctx.Done():
// TODO: Better to push ctx into next and have that control it.
err := ctx.Err()
sch.schedulingContext.TerminationReason = err.Error()
return nil, err
default:
}
Expand All @@ -121,7 +119,6 @@ func (sch *QueueScheduler) Schedule(ctx *armadacontext.Context) (*SchedulerResul
} else if schedulerconstraints.IsTerminalUnschedulableReason(unschedulableReason) {
// If unschedulableReason indicates no more new jobs can be scheduled,
// instruct the underlying iterator to only yield evicted jobs from now on.
sch.schedulingContext.TerminationReason = unschedulableReason
sch.candidateGangIterator.OnlyYieldEvicted()
} else if schedulerconstraints.IsTerminalQueueUnschedulableReason(unschedulableReason) {
// If unschedulableReason indicates no more new jobs can be scheduled for this queue,
Expand Down Expand Up @@ -196,9 +193,6 @@ func (sch *QueueScheduler) Schedule(ctx *armadacontext.Context) (*SchedulerResul
s.time.Seconds())
}))

if sch.schedulingContext.TerminationReason == "" {
sch.schedulingContext.TerminationReason = "no remaining candidate jobs"
}
if len(scheduledJobs) != len(nodeIdByJobId) {
return nil, errors.Errorf("only %d out of %d jobs mapped to a node", len(nodeIdByJobId), len(scheduledJobs))
}
Expand Down
3 changes: 0 additions & 3 deletions internal/scheduler/scheduling/queue_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,6 @@ func TestQueueScheduler(t *testing.T) {
}
}
}

// Check that we were given a termination reason.
assert.NotEmpty(t, sch.schedulingContext.TerminationReason)
})
}
}
Expand Down