Skip to content

Commit

Permalink
fix: Error if KeycloakClient secret is deleted before it (#62)
Browse files Browse the repository at this point in the history
Moved the deletion process of the KeycloakClient
before any logic that requires client secrets.
This will help avoid errors if the KeycloakClient secret
is removed before it and the deletion process gets stuck.
  • Loading branch information
zmotso committed Jun 25, 2024
1 parent ae76bc9 commit c366f12
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions controllers/keycloakclient/keycloakclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,22 @@ func (r *ReconcileKeycloakClient) tryReconcile(ctx context.Context, keycloakClie
return fmt.Errorf("unable to get keycloak realm: %w", err)
}

if err := chain.MakeChain(kClient, r.client).Serve(ctx, keycloakClient, realm); err != nil {
return fmt.Errorf("unable to serve keycloak client: %w", err)
}

if _, err := r.helper.TryToDelete(
deleted, err := r.helper.TryToDelete(
ctx,
keycloakClient,
makeTerminator(keycloakClient.Status.ClientID, realm, kClient, objectmeta.PreserveResourcesOnDeletion(keycloakClient)),
keyCloakClientOperatorFinalizerName,
); err != nil {
return pkgErrors.Wrap(err, "unable to delete kc client")
)
if err != nil {
return fmt.Errorf("deliting keycloak client: %w", err)
}

if deleted {
return nil
}

if err = chain.MakeChain(kClient, r.client).Serve(ctx, keycloakClient, realm); err != nil {
return fmt.Errorf("unable to serve keycloak client: %w", err)
}

return nil
Expand Down

0 comments on commit c366f12

Please sign in to comment.