Skip to content

Commit

Permalink
add a mutex gate to cloudprovider.Create
Browse files Browse the repository at this point in the history
this is similar to the Delete call, being added here to help prevent
possible race conditions when modifying the replica count on the
scalable resource.
  • Loading branch information
elmiko committed Aug 19, 2024
1 parent 59bf962 commit dfb56a8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ type CloudProvider struct {
}

func (c *CloudProvider) Create(ctx context.Context, nodeClaim *karpv1beta1.NodeClaim) (*karpv1beta1.NodeClaim, error) {
// to eliminate racing if multiple creation occur, we gate access to this function
c.accessLock.Lock()
defer c.accessLock.Unlock()

if nodeClaim == nil {
return nil, fmt.Errorf("cannot satisfy create, NodeClaim is nil")
}
Expand Down

0 comments on commit dfb56a8

Please sign in to comment.