Skip to content

Commit

Permalink
handle race condition where resource has already been created after t…
Browse files Browse the repository at this point in the history
…he exists check (#11)

Signed-off-by: Scott Weiss <[email protected]>
  • Loading branch information
ilackarms authored and yuval-k committed Nov 27, 2018
1 parent 596f6d9 commit 72a27ce
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/api/v1/clients/kube/resource_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ func (rc *ResourceClient) Write(resource resources.Resource, opts clients.WriteO
stats.Record(ctx, MCreates.M(1), MInFlight.M(1))
defer stats.Record(ctx, MInFlight.M(-1))
if _, err := rc.kube.ResourcesV1().Resources(meta.Namespace).Create(resourceCrd); err != nil {
if apierrors.IsAlreadyExists(err) {
return nil, errors.NewExistErr(meta)
}
return nil, errors.Wrapf(err, "creating kube resource %v", resourceCrd.Name)
}
}
Expand Down

0 comments on commit 72a27ce

Please sign in to comment.