Skip to content

Commit c2d7f5b

Browse files
Merge pull request #30233 from everettraven/oidc/route-retry
CNTRLPLANE-945: oidc: add retry logic for Keycloak route creation
2 parents 94eecf0 + 6a93b86 commit c2d7f5b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/extended/authentication/keycloak_helpers.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package authentication
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"path"
78
"time"
@@ -357,9 +358,18 @@ func createKeycloakRoute(ctx context.Context, service *corev1.Service, client ty
357358
}
358359
route.SetGroupVersionKind(routev1.SchemeGroupVersion.WithKind("Route"))
359360

360-
_, err := client.Create(ctx, route, metav1.CreateOptions{})
361-
if err != nil && !apierrors.IsAlreadyExists(err) {
362-
return nil, fmt.Errorf("creating route: %w", err)
361+
var createErr error
362+
err := wait.PollUntilContextTimeout(ctx, 10*time.Second, 5*time.Minute, true, func(ctx context.Context) (bool, error) {
363+
_, err := client.Create(ctx, route, metav1.CreateOptions{})
364+
if err != nil && !apierrors.IsAlreadyExists(err) {
365+
createErr = err
366+
return false, nil
367+
}
368+
369+
return true, nil
370+
})
371+
if err != nil {
372+
return nil, fmt.Errorf("creating route: %w", errors.Join(err, createErr))
363373
}
364374

365375
return func(ctx context.Context) error {

0 commit comments

Comments
 (0)