Skip to content

Commit 77399a9

Browse files
committed
prevent race condition
On-behalf-of: @SAP christoph.mewes@sap.com
1 parent e786eb5 commit 77399a9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

test/utils/fixtures.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434

3535
rbacv1 "k8s.io/api/rbac/v1"
3636
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
37+
apierrors "k8s.io/apimachinery/pkg/api/errors"
3738
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3839
"k8s.io/apimachinery/pkg/util/wait"
3940
"k8s.io/apimachinery/pkg/util/yaml"
@@ -129,7 +130,7 @@ func CreateAPIExport(t *testing.T, ctx context.Context, client ctrlruntimeclient
129130
}
130131

131132
// In kcp 0.27, we have to manually create the AEES. To make the tests work consistently with
132-
// 0.27 and later versions, we simply always create one.
133+
// 0.27 and later versions, we simply always create one if it's missing.
133134
endpointSlice := &kcpapisv1alpha1.APIExportEndpointSlice{
134135
ObjectMeta: metav1.ObjectMeta{
135136
Name: name,
@@ -142,7 +143,7 @@ func CreateAPIExport(t *testing.T, ctx context.Context, client ctrlruntimeclient
142143
}
143144

144145
t.Logf("Creating APIExportEndpointSlice %q…", endpointSlice.Name)
145-
if err := client.Create(ctx, endpointSlice); err != nil {
146+
if err := client.Create(ctx, endpointSlice); err != nil && !apierrors.IsAlreadyExists(err) {
146147
t.Fatalf("Failed to create APIExportEndpointSlice: %v", err)
147148
}
148149

0 commit comments

Comments
 (0)