From b51e730fc889fa968eadc70c3a804c084bf00fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Muzik=C3=A1=C5=99?= Date: Thu, 1 Feb 2024 17:53:23 +0100 Subject: [PATCH] Upgrade to Quarkus 3.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #26701 Closes #23854 Signed-off-by: Václav Muzikář --- pom.xml | 4 +- .../quarkus/deployment/KeycloakProcessor.java | 23 +++++--- .../health/ReactiveHealthHandler.java | 57 ------------------- .../health/ReactiveLivenessHandler.java | 35 ------------ .../health/ReactiveReadinessHandler.java | 35 ------------ .../health/KeycloakReadyAsyncHealthCheck.java | 23 ++------ .../src/main/resources/application.properties | 1 - testsuite/utils/pom.xml | 1 + 8 files changed, 22 insertions(+), 157 deletions(-) delete mode 100644 quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveHealthHandler.java delete mode 100644 quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveLivenessHandler.java delete mode 100644 quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveReadinessHandler.java diff --git a/pom.xml b/pom.xml index deae3e60e419..60a97aa679ff 100644 --- a/pom.xml +++ b/pom.xml @@ -45,8 +45,8 @@ jboss-snapshots-repository https://s01.oss.sonatype.org/content/repositories/snapshots/ - 3.7.0.CR1 - 3.7.0.CR1 + 3.7.1 + 3.7.1 ${timestamp} diff --git a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java index 1c468711d1fe..f447b1259377 100644 --- a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java +++ b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java @@ -17,9 +17,12 @@ package org.keycloak.quarkus.deployment; +import io.quarkus.agroal.runtime.health.DataSourceHealthCheck; import io.quarkus.agroal.spi.JdbcDataSourceBuildItem; import io.quarkus.agroal.spi.JdbcDriverBuildItem; +import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; import io.quarkus.arc.deployment.BuildTimeConditionBuildItem; +import io.quarkus.arc.processor.AnnotationsTransformer; import io.quarkus.bootstrap.logging.InitialConfigurator; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceResultBuildItem; import io.quarkus.deployment.IsDevelopment; @@ -45,6 +48,7 @@ import io.quarkus.vertx.http.deployment.RouteBuildItem; import io.quarkus.resteasy.reactive.spi.IgnoreStackMixingBuildItem; import io.smallrye.config.ConfigValue; +import org.eclipse.microprofile.health.Readiness; import org.hibernate.cfg.AvailableSettings; import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor; import org.hibernate.jpa.boot.internal.PersistenceXmlParser; @@ -82,8 +86,6 @@ import org.keycloak.provider.ProviderFactory; import org.keycloak.provider.ProviderManager; import org.keycloak.provider.Spi; -import org.keycloak.quarkus.runtime.integration.health.ReactiveLivenessHandler; -import org.keycloak.quarkus.runtime.integration.health.ReactiveReadinessHandler; import org.keycloak.quarkus.runtime.Environment; import org.keycloak.quarkus.runtime.KeycloakRecorder; import org.keycloak.quarkus.runtime.configuration.Configuration; @@ -616,12 +618,6 @@ void disableHealthEndpoint(BuildProducer routes, BuildProducer routes, BuildProducer c.name().equals(DotName.createSimple(DataSourceHealthCheck.class))) + .thenTransform(t -> t.remove( + a -> a.name().equals(DotName.createSimple(Readiness.class))))); + } + @BuildStep void configureResteasy(CombinedIndexBuildItem index, BuildProducer buildTimeConditionBuildItemBuildProducer, diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveHealthHandler.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveHealthHandler.java deleted file mode 100644 index 7d3d98a19843..000000000000 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveHealthHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.quarkus.runtime.integration.health; - -import io.quarkus.smallrye.health.runtime.SmallRyeLivenessHandler; -import io.smallrye.health.SmallRyeHealth; -import io.smallrye.health.SmallRyeHealthReporter; -import io.smallrye.mutiny.Uni; -import io.vertx.core.Handler; -import io.vertx.ext.web.RoutingContext; - -/** - * This adds the possibility to have a non-blocking health handler in Quarkus. - *

- * Without a non-blocking health check, all liveness and readiness probes will enqueue in the worker thread pool. Under high load - * of if there is a lot of blocking IO happening (for example, during Keycloak cluster rebalancing), this leads to probes being queued. - * Queued probes would lead to timeouts unless the timeouts are configured to 10-20 seconds. Reactive probes avoid the enqueueing - * in the worker thread pool for all non-blocking probes, which will be the default for the (otherwise empty) liveness probe. - * For the readiness probe, this depends on the implementation of the specific readiness probes. - *

- * This is a workaround until quarkusio/quarkus#35100 is available - * in a regular Quarkus version. Then these classes can be removed. - * - * @author Alexander Schwartz - */ -public abstract class ReactiveHealthHandler implements Handler { - - @Override - public void handle(RoutingContext context) { - Uni health = getHealth(); - health.subscribe().with(smallRyeHealth -> { - new SmallRyeLivenessHandler() { - @Override - protected SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext ctx) { - return smallRyeHealth; - } - }.handle(context); - }); - } - - protected abstract Uni getHealth(); -} diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveLivenessHandler.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveLivenessHandler.java deleted file mode 100644 index c5e5c6db4d9d..000000000000 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveLivenessHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.quarkus.runtime.integration.health; - -import io.quarkus.arc.Arc; -import io.smallrye.health.SmallRyeHealth; -import io.smallrye.health.SmallRyeHealthReporter; -import io.smallrye.mutiny.Uni; - -/** - * @author Alexander Schwartz - */ -public class ReactiveLivenessHandler extends ReactiveHealthHandler { - - @Override - protected Uni getHealth() { - SmallRyeHealthReporter healthReporter = Arc.container().instance(SmallRyeHealthReporter.class).get(); - return healthReporter.getLivenessAsync(); - } -} diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveReadinessHandler.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveReadinessHandler.java deleted file mode 100644 index 5900a2cbbd92..000000000000 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/health/ReactiveReadinessHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.quarkus.runtime.integration.health; - -import io.quarkus.arc.Arc; -import io.smallrye.health.SmallRyeHealth; -import io.smallrye.health.SmallRyeHealthReporter; -import io.smallrye.mutiny.Uni; - -/** - * @author Alexander Schwartz - */ -public class ReactiveReadinessHandler extends ReactiveHealthHandler { - - @Override - protected Uni getHealth() { - SmallRyeHealthReporter healthReporter = Arc.container().instance(SmallRyeHealthReporter.class).get(); - return healthReporter.getReadinessAsync(); - } -} diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/services/health/KeycloakReadyAsyncHealthCheck.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/services/health/KeycloakReadyAsyncHealthCheck.java index 86264224319f..d3a8c200dbce 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/services/health/KeycloakReadyAsyncHealthCheck.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/services/health/KeycloakReadyAsyncHealthCheck.java @@ -21,7 +21,6 @@ import io.quarkus.smallrye.health.runtime.QuarkusAsyncHealthCheckFactory; import io.smallrye.health.api.AsyncHealthCheck; import io.smallrye.mutiny.Uni; -import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import org.eclipse.microprofile.health.HealthCheckResponse; @@ -50,23 +49,6 @@ @ApplicationScoped public class KeycloakReadyAsyncHealthCheck implements AsyncHealthCheck { - /** As the DataSourceHealthCheck doesn't exist as an application scoped bean, - * create our own instance here which exposes the init() call for the delegate. */ - MyDataSourceHealthCheck delegate; - - private static class MyDataSourceHealthCheck extends DataSourceHealthCheck { - @Override - public void init() { - super.init(); - } - } - - @PostConstruct - protected void init() { - delegate = new MyDataSourceHealthCheck(); - delegate.init(); - } - /** * Date formatter, the same as used by Quarkus. This enables users to quickly compare the date printed * by the probe with the logs. @@ -79,6 +61,9 @@ protected void init() { @Inject QuarkusAsyncHealthCheckFactory healthCheckFactory; + @Inject + DataSourceHealthCheck dataSourceHealthCheck; + AtomicReference failingSince = new AtomicReference<>(); @Override @@ -88,7 +73,7 @@ public Uni call() { long invalidCount = agroalDataSource.getMetrics().invalidCount(); if (activeCount < 1 || invalidCount > 0) { return healthCheckFactory.callSync(() -> { - HealthCheckResponse activeCheckResult = delegate.call(); + HealthCheckResponse activeCheckResult = dataSourceHealthCheck.call(); if (activeCheckResult.getStatus() == HealthCheckResponse.Status.DOWN) { builder.down(); Instant failingTime = failingSince.updateAndGet(this::createInstanceIfNeeded); diff --git a/quarkus/runtime/src/main/resources/application.properties b/quarkus/runtime/src/main/resources/application.properties index c369cf48d2c7..9e9fd366136b 100644 --- a/quarkus/runtime/src/main/resources/application.properties +++ b/quarkus/runtime/src/main/resources/application.properties @@ -7,7 +7,6 @@ quarkus.banner.enabled=false # Disable health checks from extensions, since we provide our own (default is true) quarkus.health.extensions.enabled=false -quarkus.datasource.health.enabled=false # Disable http metrics binder as URL parameters are only shown with placeholders for '/resource' URLs, but not # for '/admin' and '/realms'. Neither the IDs of entities nor the realm name should be part of the metric names diff --git a/testsuite/utils/pom.xml b/testsuite/utils/pom.xml index 96cf6d67e92b..8f11485ab134 100755 --- a/testsuite/utils/pom.xml +++ b/testsuite/utils/pom.xml @@ -266,6 +266,7 @@ mysql mysql-connector-java + ${mysql-jdbc.version} compile