Skip to content

Commit

Permalink
Rename GetRequirements
Browse files Browse the repository at this point in the history
  • Loading branch information
zuqq committed Jun 26, 2023
1 parent 1c3ae70 commit 9d765e5
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/scheduler/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func PodRequirementFromLegacySchedulerJob[E interfaces.LegacySchedulerJob](job E
}
annotations[schedulerconfig.JobIdAnnotation] = job.GetId()
annotations[schedulerconfig.QueueAnnotation] = job.GetQueue()
info := job.GetRequirements(priorityClasses)
info := job.GetJobSchedulingInfo(priorityClasses)
req := PodRequirementFromJobSchedulingInfo(info)
req.Annotations = annotations
return req
Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/context/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ func testSmallCpuJobSchedulingContext(queue, priorityClassName string) *JobSched
NumNodes: 1,
JobId: job.GetId(),
Job: job,
Req: job.GetRequirements(nil).ObjectRequirements[0].GetPodRequirements(),
Req: job.GetJobSchedulingInfo(nil).ObjectRequirements[0].GetPodRequirements(),
}
}
2 changes: 1 addition & 1 deletion internal/scheduler/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type LegacySchedulerJob interface {
GetPerQueuePriority() uint32
GetSubmitTime() time.Time
GetAnnotations() map[string]string
GetRequirements(map[string]configuration.PriorityClass) *schedulerobjects.JobSchedulingInfo
GetJobSchedulingInfo(map[string]configuration.PriorityClass) *schedulerobjects.JobSchedulingInfo
GetPriorityClassName() string
GetNodeSelector() map[string]string
GetAffinity() *v1.Affinity
Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/jobdb/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (job *Job) GetAnnotations() map[string]string {

// GetRequirements returns the scheduling requirements associated with the job.
// Needed for compatibility with interfaces.LegacySchedulerJob
func (job *Job) GetRequirements(_ map[string]configuration.PriorityClass) *schedulerobjects.JobSchedulingInfo {
func (job *Job) GetJobSchedulingInfo(_ map[string]configuration.PriorityClass) *schedulerobjects.JobSchedulingInfo {
return job.JobSchedulingInfo()
}

Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/jobdb/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestJob_TestGetter(t *testing.T) {
assert.Equal(t, baseJob.queue, baseJob.Queue())
assert.Equal(t, baseJob.queue, baseJob.GetQueue())
assert.Equal(t, baseJob.created, baseJob.Created())
assert.Equal(t, schedulingInfo, baseJob.GetRequirements(nil))
assert.Equal(t, schedulingInfo, baseJob.GetJobSchedulingInfo(nil))
assert.Equal(t, schedulingInfo, baseJob.JobSchedulingInfo())
assert.Equal(t, baseJob.GetAnnotations(), map[string]string{
"foo": "bar",
Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/preempting_queue_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ func defaultPostEvictFunc(ctx context.Context, job interfaces.LegacySchedulerJob

// Add a toleration to allow the job to be re-scheduled even if node is unschedulable.
//
// TODO: Because req is allocated by GetRequirements() if job is an api.Job, this toleration may not persist.
// TODO: Because req is allocated by GetJobSchedulingInfo() if job is an api.Job, this toleration may not persist.
// In practice, this isn't an issue now since we don't check static requirements for evicted jobs.
if node.Unschedulable {
req.Tolerations = append(req.Tolerations, nodedb.UnschedulableToleration())
Expand Down
4 changes: 2 additions & 2 deletions internal/scheduler/testfixtures/testfixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func WithRequestsPodReqs(rl schedulerobjects.ResourceList, reqs []*schedulerobje

func WithNodeSelectorJobs(selector map[string]string, jobs []*jobdb.Job) []*jobdb.Job {
for _, job := range jobs {
for _, req := range job.GetRequirements(nil).GetObjectRequirements() {
for _, req := range job.GetJobSchedulingInfo(nil).GetObjectRequirements() {
req.GetPodRequirements().NodeSelector = maps.Clone(selector)
}
}
Expand All @@ -284,7 +284,7 @@ func WithGangAnnotationsJobs(jobs []*jobdb.Job) []*jobdb.Job {

func WithAnnotationsJobs(annotations map[string]string, jobs []*jobdb.Job) []*jobdb.Job {
for _, job := range jobs {
for _, req := range job.GetRequirements(nil).GetObjectRequirements() {
for _, req := range job.GetJobSchedulingInfo(nil).GetObjectRequirements() {
if req.GetPodRequirements().Annotations == nil {
req.GetPodRequirements().Annotations = make(map[string]string)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (job *Job) GetSubmitTime() time.Time {
return job.Created
}

func (job *Job) GetRequirements(priorityClasses map[string]configuration.PriorityClass) *schedulerobjects.JobSchedulingInfo {
func (job *Job) GetJobSchedulingInfo(priorityClasses map[string]configuration.PriorityClass) *schedulerobjects.JobSchedulingInfo {
podSpec := job.GetMainPodSpec()

priority, ok := PriorityFromPodSpec(podSpec, priorityClasses)
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func TestJobGetRequirements(t *testing.T) {
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
assert.Equal(t, tc.expected, tc.job.GetRequirements(TestPriorityClasses))
assert.Equal(t, tc.expected, tc.job.GetJobSchedulingInfo(TestPriorityClasses))
})
}
}
Expand Down

0 comments on commit 9d765e5

Please sign in to comment.