Skip to content

Commit

Permalink
[YUNIKORN-2951] Remove unnecessary locking from RequiredNodePreemptor (
Browse files Browse the repository at this point in the history
…#989)

Closes: #989

Signed-off-by: Craig Condit <ccondit@apache.org>
  • Loading branch information
ryankert01 authored and craigcondit committed Oct 29, 2024
1 parent 5d3eb36 commit 19fefc6
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions pkg/scheduler/objects/required_node_preemptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ import (
"sort"

"github.com/apache/yunikorn-core/pkg/common/resources"
"github.com/apache/yunikorn-core/pkg/locking"
)

type PreemptionContext struct {
node *Node
requiredAsk *Allocation
allocations []*Allocation

locking.RWMutex
}

func NewRequiredNodePreemptor(node *Node, requiredAsk *Allocation) *PreemptionContext {
Expand All @@ -43,8 +40,6 @@ func NewRequiredNodePreemptor(node *Node, requiredAsk *Allocation) *PreemptionCo
}

func (p *PreemptionContext) filterAllocations() {
p.Lock()
defer p.Unlock()
for _, allocation := range p.node.GetYunikornAllocations() {
// skip daemon set pods and higher priority allocation
if allocation.GetRequiredNode() != "" || allocation.GetPriority() > p.requiredAsk.GetPriority() {
Expand Down Expand Up @@ -76,8 +71,6 @@ func (p *PreemptionContext) filterAllocations() {
// 3. By Create time or age of the ask (younger ask placed first),
// 4. By resource (ask with lesser allocated resources placed first)
func (p *PreemptionContext) sortAllocations() {
p.Lock()
defer p.Unlock()
sort.SliceStable(p.allocations, func(i, j int) bool {
l := p.allocations[i]
r := p.allocations[j]
Expand Down Expand Up @@ -129,8 +122,6 @@ func (p *PreemptionContext) sortAllocations() {
}

func (p *PreemptionContext) GetVictims() []*Allocation {
p.RLock()
defer p.RUnlock()
var victims []*Allocation
var currentResource = resources.NewResource()
for _, allocation := range p.allocations {
Expand All @@ -152,7 +143,5 @@ func (p *PreemptionContext) GetVictims() []*Allocation {

// for test only
func (p *PreemptionContext) getAllocations() []*Allocation {
p.RLock()
defer p.RUnlock()
return p.allocations
}

0 comments on commit 19fefc6

Please sign in to comment.