Skip to content

Commit 6a93b86

Browse files
committed
oidc: add retry logic for Keycloak route creation
Signed-off-by: Bryce Palmer <[email protected]>
1 parent c21df2e commit 6a93b86

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"
@@ -356,9 +357,18 @@ func createKeycloakRoute(ctx context.Context, service *corev1.Service, client ty
356357
}
357358
route.SetGroupVersionKind(routev1.SchemeGroupVersion.WithKind("Route"))
358359

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

364374
return func(ctx context.Context) error {

0 commit comments

Comments
 (0)