Skip to content

Commit

Permalink
Keycloak DevService: Improve error messages and documentation for cli…
Browse files Browse the repository at this point in the history
…ent timeouts
  • Loading branch information
Felk authored and sberyozkin committed Nov 6, 2023
1 parent 2776bde commit 672348a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public String getGrantType() {
* The WebClient timeout.
* Use this property to configure how long an HTTP client used by Dev UI handlers will wait for a response when requesting
* tokens from OpenId Connect Provider and sending them to the service endpoint.
* This timeout is also used by the OIDC dev service admin client.
*/
@ConfigItem(defaultValue = "4S")
public Duration webClientTimeout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import io.quarkus.oidc.runtime.devui.OidcDevServicesUtils;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ConfigUtils;
import io.smallrye.mutiny.TimeoutException;
import io.smallrye.mutiny.Uni;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpHeaders;
Expand Down Expand Up @@ -626,8 +627,11 @@ private String getAdminToken(WebClient client, String keycloakUrl) {
keycloakUrl + "/realms/master/protocol/openid-connect/token",
"admin-cli", null, "admin", "admin", null)
.await().atMost(oidcConfig.devui.webClientTimeout);
} catch (TimeoutException e) {
LOG.error("Admin token can not be acquired due to a client connection timeout. " +
"You may try increasing the `quarkus.oidc.devui.web-client-timeout` property.");
} catch (Throwable t) {
LOG.errorf("Admin token can not be acquired: %s", t.getMessage());
LOG.error("Admin token can not be acquired", t);
}
return null;
}
Expand Down Expand Up @@ -673,7 +677,7 @@ private void createRealm(WebClient client, String token, String keycloakUrl, Rea
} catch (Throwable t) {
errors.add(String.format("Realm %s can not be created: %s", realm.getRealm(), t.getMessage()));

LOG.errorf("Realm %s can not be created: %s", realm.getRealm(), t.getMessage());
LOG.errorf(t, "Realm %s can not be created", realm.getRealm());
}
}

Expand Down

0 comments on commit 672348a

Please sign in to comment.