Skip to content

Commit

Permalink
Merge pull request kubernetes#5584 from XavierDuthil/ovhcloud/fix-mul…
Browse files Browse the repository at this point in the history
…tiple-scale-down

ovhcloud: Fix deletion of multiple nodes at the same time
  • Loading branch information
k8s-ci-robot authored Mar 16, 2023
2 parents 205eeca + 0907390 commit 606ca3b
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math"
"math/rand"
"strings"
"sync"
"time"

apiv1 "k8s.io/api/core/v1"
Expand All @@ -44,6 +45,7 @@ type NodeGroup struct {

Manager *OvhCloudManager
CurrentSize int
mutex sync.Mutex
}

// MaxSize returns maximum size of the node pool.
Expand Down Expand Up @@ -111,6 +113,12 @@ func (ng *NodeGroup) IncreaseSize(delta int) error {

// DeleteNodes deletes the nodes from the group.
func (ng *NodeGroup) DeleteNodes(nodes []*apiv1.Node) error {
// DeleteNodes is called in goroutine so it can run in parallel
// Goroutines created in: ScaleDown.scheduleDeleteEmptyNodes()
// Adding mutex to ensure CurrentSize attribute keeps consistency
ng.mutex.Lock()
defer ng.mutex.Unlock()

// Do not use node group which does not support autoscaling
if !ng.Autoscale {
return nil
Expand Down

0 comments on commit 606ca3b

Please sign in to comment.