Skip to content

Commit

Permalink
Merge pull request #13 from elmiko/add-access-lock-create
Browse files Browse the repository at this point in the history
add a mutex gate to cloudprovider.Create
  • Loading branch information
elmiko authored Aug 19, 2024
2 parents 59bf962 + dfb56a8 commit 6619963
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 6619963

Please sign in to comment.