Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
severinson committed Nov 17, 2023
1 parent 7b5c246 commit 052ddbd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 26 deletions.
16 changes: 0 additions & 16 deletions internal/scheduler/jobdb/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,6 @@ func (job *Job) WithRequestedPriority(priority uint32) *Job {
return j
}

// WithNodeSelectorTerm returns a copy of the job with a node selector term added to it.
func (job *Job) WithNodeSelectorTerm(key, value string) *Job {
copiedSchedulingInfo := proto.Clone(job.JobSchedulingInfo()).(*schedulerobjects.JobSchedulingInfo)
j := job.WithJobSchedulingInfo(copiedSchedulingInfo)
for _, oreq := range j.jobSchedulingInfo.ObjectRequirements {
if preq := oreq.GetPodRequirements(); preq != nil {
if preq.NodeSelector == nil {
preq.NodeSelector = map[string]string{key: value}
} else {
preq.NodeSelector[key] = value
}
}
}
return j
}

// JobSchedulingInfo returns the scheduling requirements associated with the job
func (job *Job) JobSchedulingInfo() *schedulerobjects.JobSchedulingInfo {
return job.jobSchedulingInfo
Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/nodedb/nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ func (nodeDb *NodeDb) NodeTypesMatchingPod(req *schedulerobjects.PodRequirements
selectedNodeTypes := make([]*schedulerobjects.NodeType, 0)
numExcludedNodesByReason := make(map[string]int)
for _, nodeType := range nodeDb.nodeTypes {
matches, reason, err := nodeType.PodRequirementsMet(req)
matches, reason, err := schedulerobjects.NodeTypePodRequirementsMet(nodeType, req)
if err != nil {
return nil, nil, err
}
Expand Down
10 changes: 2 additions & 8 deletions internal/scheduler/schedulerobjects/nodematching.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ func (err *InsufficientResources) String() string {
err.Available.String() + " is available"
}

// PodRequirementsMet determines whether a pod can be scheduled on nodes of this NodeType.
// NodeTypePodRequirementsMet determines whether a pod can be scheduled on nodes of this NodeType.
// If the requirements are not met, it returns the reason for why.
// If the requirements can't be parsed, an error is returned.
func (nodeType *NodeType) PodRequirementsMet(req *PodRequirements) (bool, PodRequirementsNotMetReason, error) {
func NodeTypePodRequirementsMet(nodeType *NodeType, req *PodRequirements) (bool, PodRequirementsNotMetReason, error) {
matches, reason, err := podTolerationRequirementsMet(nodeType.GetTaints(), req)
if !matches || err != nil {
return matches, reason, err
Expand All @@ -134,12 +134,6 @@ func PodRequirementsMet(taints []v1.Taint, labels map[string]string, totalResour
return DynamicPodRequirementsMet(allocatableResources, req)
}

// StaticJobRequirementsMet checks if a pod can be scheduled onto this node,
// accounting for taints, node selectors, node affinity, and total resources available on the node.
func StaticJobRequirementsMet(taints []v1.Taint, labels map[string]string, totalResources ResourceList, jctx *schedulercontext.JobSchedulingContext) (bool, PodRequirementsNotMetReason, error) {

}

// StaticPodRequirementsMet checks if a pod can be scheduled onto this node,
// accounting for taints, node selectors, node affinity, and total resources available on the node.
func StaticPodRequirementsMet(taints []v1.Taint, labels map[string]string, totalResources ResourceList, req *PodRequirements) (bool, PodRequirementsNotMetReason, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/schedulerobjects/nodematching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func TestNodeTypeSchedulingRequirementsMet(t *testing.T) {
tc.IndexedTaints,
tc.IndexedLabels,
)
matches, reason, err := nodeType.PodRequirementsMet(tc.Req)
matches, reason, err := NodeTypePodRequirementsMet(nodeType, tc.Req)
assert.NoError(t, err)
if tc.ExpectSuccess {
assert.True(t, matches)
Expand Down

0 comments on commit 052ddbd

Please sign in to comment.