Skip to content

Commit

Permalink
fix: log an error with keyword failed, as this is what I am looking f…
Browse files Browse the repository at this point in the history
…or in the logs
  • Loading branch information
christianwoehrle committed Aug 13, 2022
1 parent 55c6d17 commit 953983b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/common/cluster_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,26 @@ func (i *ClusterActionRunner) CreateClient(obj *v1alpha1.KeycloakClient, realm s
return i.client.Update(i.context, obj)
}

log.Error(err, "create client failed for client %s", obj.Spec.Client.Name)
log.Info(fmt.Sprintf("FAILED: create client failed for client %s with error %s", obj.Spec.Client.Name, err))

if err.Error() == "failed to create client: (409) 409 Conflict" {
log.Info(" retry create client after 409 Conclict")

uid, err2 := i.keycloakClient.GetClientID(obj.Spec.Client.ClientID, realm)

if err2 != nil {
return errors.Errorf("cannot perform client create because of %s followed by %s", err.Error(), err2.Error())
return errors.Errorf(fmt.Sprintf("cannot perform client create because of %s followed by %s", err.Error(), err2.Error()))
}
err3 := i.keycloakClient.DeleteClient(uid, realm)
if err3 != nil {
return errors.Errorf("cannot perform client create because of %s followed by %s", err.Error(), err3.Error())
return errors.Errorf(fmt.Sprintf("cannot perform client create because of %s followed by %s", err.Error(), err3.Error()))
}
log.Info(fmt.Sprintf(" client %s deleted", obj.Spec.Client.Name))

uid, err := i.keycloakClient.CreateClient(obj.Spec.Client, realm)

if err == nil {
obj.Spec.Client.ID = uid

return i.client.Update(i.context, obj)
}
}
Expand Down

0 comments on commit 953983b

Please sign in to comment.