Skip to content

Commit

Permalink
UPSTREAM: <carry>: Add mutex to DeleteNodes
Browse files Browse the repository at this point in the history
This change adds a mutex to the MachineController structure which is
used to gate access to the DeleteNodes function.

This is one in a series of PRs to mitigate kubernetes#3104
Once a solution has been reached, this will be contribued upstream.
  • Loading branch information
elmiko committed May 5, 2020
1 parent b7b1e90 commit 9e22789
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"os"
"strings"
"sync"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -62,6 +63,7 @@ type machineController struct {
machineSetResource *schema.GroupVersionResource
machineResource *schema.GroupVersionResource
machineDeploymentResource *schema.GroupVersionResource
accessLock sync.Mutex
}

type machineSetFilterFunc func(machineSet *MachineSet) error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (ng *nodegroup) IncreaseSize(delta int) error {
// group. This function should wait until node group size is updated.
// Implementation required.
func (ng *nodegroup) DeleteNodes(nodes []*corev1.Node) error {
ng.machineController.accessLock.Lock()
defer ng.machineController.accessLock.Unlock()

replicas, err := ng.scalableResource.Replicas()
if err != nil {
return err
Expand Down

0 comments on commit 9e22789

Please sign in to comment.