Remove additional handlers for health and metrics endpoints (#27615)
Closes #27614 Signed-off-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
parent
653d09f39a
commit
767a7ecafb
2 changed files with 2 additions and 51 deletions
|
@ -45,7 +45,6 @@ import io.quarkus.hibernate.orm.deployment.spi.AdditionalJpaModelBuildItem;
|
|||
import io.quarkus.resteasy.reactive.server.spi.MethodScannerBuildItem;
|
||||
import io.quarkus.runtime.configuration.ConfigurationException;
|
||||
import io.quarkus.runtime.configuration.ProfileManager;
|
||||
import io.quarkus.vertx.http.deployment.RouteBuildItem;
|
||||
import io.smallrye.config.ConfigValue;
|
||||
import org.eclipse.microprofile.health.Readiness;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
@ -94,7 +93,6 @@ import org.keycloak.quarkus.runtime.configuration.QuarkusPropertiesConfigSource;
|
|||
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper;
|
||||
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;
|
||||
import org.keycloak.quarkus.runtime.integration.resteasy.KeycloakHandlerChainCustomizer;
|
||||
import org.keycloak.quarkus.runtime.integration.web.NotFoundHandler;
|
||||
import org.keycloak.quarkus.runtime.services.health.KeycloakReadyHealthCheck;
|
||||
import org.keycloak.quarkus.runtime.storage.database.jpa.NamedJpaConnectionProviderFactory;
|
||||
import org.keycloak.quarkus.runtime.themes.FlatClasspathThemeResourceProviderFactory;
|
||||
|
@ -147,8 +145,6 @@ import java.util.logging.Handler;
|
|||
import static org.keycloak.connections.jpa.util.JpaUtils.loadSpecificNamedQueries;
|
||||
import static org.keycloak.quarkus.runtime.Environment.getCurrentOrCreateFeatureProfile;
|
||||
import static org.keycloak.quarkus.runtime.Environment.getProviderFiles;
|
||||
import static org.keycloak.quarkus.runtime.KeycloakRecorder.DEFAULT_HEALTH_ENDPOINT;
|
||||
import static org.keycloak.quarkus.runtime.KeycloakRecorder.DEFAULT_METRICS_ENDPOINT;
|
||||
import static org.keycloak.quarkus.runtime.Providers.getProviderManager;
|
||||
import static org.keycloak.quarkus.runtime.configuration.Configuration.getOptionalKcValue;
|
||||
import static org.keycloak.quarkus.runtime.configuration.Configuration.getOptionalValue;
|
||||
|
@ -600,24 +596,8 @@ class KeycloakProcessor {
|
|||
}
|
||||
|
||||
@BuildStep
|
||||
void disableMetricsEndpoint(BuildProducer<RouteBuildItem> routes) {
|
||||
if (!isMetricsEnabled()) {
|
||||
routes.produce(RouteBuildItem.builder().route(DEFAULT_METRICS_ENDPOINT.concat("/*")).handler(new NotFoundHandler()).build());
|
||||
}
|
||||
}
|
||||
|
||||
@BuildStep
|
||||
void disableHealthEndpoint(BuildProducer<RouteBuildItem> routes, BuildProducer<BuildTimeConditionBuildItem> removeBeans,
|
||||
CombinedIndexBuildItem index) {
|
||||
boolean healthDisabled = !isHealthEnabled();
|
||||
|
||||
if (healthDisabled) {
|
||||
routes.produce(RouteBuildItem.builder().route(DEFAULT_HEALTH_ENDPOINT.concat("/*")).handler(new NotFoundHandler()).build());
|
||||
}
|
||||
|
||||
boolean metricsDisabled = !isMetricsEnabled();
|
||||
|
||||
if (healthDisabled || metricsDisabled) {
|
||||
void disableHealthCheckBean(BuildProducer<BuildTimeConditionBuildItem> removeBeans, CombinedIndexBuildItem index) {
|
||||
if (!isHealthEnabled() || !isMetricsEnabled()) {
|
||||
// disables the single check we provide which depends on metrics enabled
|
||||
ClassInfo disabledBean = index.getIndex()
|
||||
.getClassByName(DotName.createSimple(KeycloakReadyHealthCheck.class.getName()));
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright 2021 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.web;
|
||||
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
|
||||
public class NotFoundHandler implements Handler<RoutingContext> {
|
||||
|
||||
@Override
|
||||
public void handle(RoutingContext event) {
|
||||
event.fail(404);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue