Skip to content

Commit

Permalink
Upgrade to Quarkus 3.7.1
Browse files Browse the repository at this point in the history
Closes keycloak#26701
Closes keycloak#23854

Signed-off-by: Václav Muzikář <[email protected]>
  • Loading branch information
vmuzikar committed Feb 2, 2024
1 parent 65c7cd6 commit b51e730
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 157 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<jboss.snapshots.repo.id>jboss-snapshots-repository</jboss.snapshots.repo.id>
<jboss.snapshots.repo.url>https://s01.oss.sonatype.org/content/repositories/snapshots/</jboss.snapshots.repo.url>

<quarkus.version>3.7.0.CR1</quarkus.version>
<quarkus.build.version>3.7.0.CR1</quarkus.build.version>
<quarkus.version>3.7.1</quarkus.version>
<quarkus.build.version>3.7.1</quarkus.build.version>

<project.build-time>${timestamp}</project.build-time>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -616,12 +618,6 @@ void disableHealthEndpoint(BuildProducer<RouteBuildItem> routes, BuildProducer<B

if (healthDisabled) {
routes.produce(RouteBuildItem.builder().route(DEFAULT_HEALTH_ENDPOINT.concat("/*")).handler(new NotFoundHandler()).build());
} else {
// local solution until https://github.com/quarkusio/quarkus/issues/35099 is available in Quarkus
if (!isHealthClassicProbesEnabled()) {
routes.produce(RouteBuildItem.builder().route(DEFAULT_HEALTH_ENDPOINT.concat("/live")).handler(new ReactiveLivenessHandler()).build());
routes.produce(RouteBuildItem.builder().route(DEFAULT_HEALTH_ENDPOINT.concat("/ready")).handler(new ReactiveReadinessHandler()).build());
}
}

boolean metricsDisabled = !isMetricsEnabled();
Expand Down Expand Up @@ -649,6 +645,17 @@ void disableHealthEndpoint(BuildProducer<RouteBuildItem> routes, BuildProducer<B
}
}

// We can't use quarkus.datasource.health.enabled=false as that would remove the DataSourceHealthCheck from CDI and
// it can't be instantiated via constructor as it now includes some field injection points. So we just make it a regular
// bean without the @Readiness annotation so it won't be used as a health check on it's own.
@BuildStep
AnnotationsTransformerBuildItem disableDefaultDataSourceHealthCheck() {
return new AnnotationsTransformerBuildItem(AnnotationsTransformer.appliedToClass()
.whenClass(c -> 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<BuildTimeConditionBuildItem> buildTimeConditionBuildItemBuildProducer,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <code>init()</code> 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.
Expand All @@ -79,6 +61,9 @@ protected void init() {
@Inject
QuarkusAsyncHealthCheckFactory healthCheckFactory;

@Inject
DataSourceHealthCheck dataSourceHealthCheck;

AtomicReference<Instant> failingSince = new AtomicReference<>();

@Override
Expand All @@ -88,7 +73,7 @@ public Uni<HealthCheckResponse> 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);
Expand Down
1 change: 0 additions & 1 deletion quarkus/runtime/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions testsuite/utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-jdbc.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down

0 comments on commit b51e730

Please sign in to comment.