From 1a4bbdcd3ac17552575721156aaafbd67115b589 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Thu, 4 Jan 2024 12:56:08 +0200 Subject: [PATCH] Disable Kubernetes Config when in AppCDs generation Closes: #38020 --- .../io/quarkus/arc/runtime/appcds/AppCDSRecorder.java | 4 +++- .../runtime/KubernetesConfigSourceFactoryBuilder.java | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/appcds/AppCDSRecorder.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/appcds/AppCDSRecorder.java index 70e03db0d3545..1f5e5a37b5b83 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/appcds/AppCDSRecorder.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/appcds/AppCDSRecorder.java @@ -7,8 +7,10 @@ @Recorder public class AppCDSRecorder { + public static final String QUARKUS_APPCDS_GENERATE_PROP = "quarkus.appcds.generate"; + public void controlGenerationAndExit() { - if (Boolean.parseBoolean(System.getProperty("quarkus.appcds.generate", "false"))) { + if (Boolean.parseBoolean(System.getProperty(QUARKUS_APPCDS_GENERATE_PROP, "false"))) { InitializationTaskRecorder.preventFurtherRecorderSteps(5, "Unable to properly shutdown Quarkus application when creating AppCDS", PreventFurtherStepsException::new); diff --git a/extensions/kubernetes-config/runtime/src/main/java/io/quarkus/kubernetes/config/runtime/KubernetesConfigSourceFactoryBuilder.java b/extensions/kubernetes-config/runtime/src/main/java/io/quarkus/kubernetes/config/runtime/KubernetesConfigSourceFactoryBuilder.java index 1cd67db69e6e4..2b7b40fe012a3 100644 --- a/extensions/kubernetes-config/runtime/src/main/java/io/quarkus/kubernetes/config/runtime/KubernetesConfigSourceFactoryBuilder.java +++ b/extensions/kubernetes-config/runtime/src/main/java/io/quarkus/kubernetes/config/runtime/KubernetesConfigSourceFactoryBuilder.java @@ -2,9 +2,12 @@ import static io.smallrye.config.Converters.getImplicitConverter; +import java.util.Collections; + import org.eclipse.microprofile.config.spi.ConfigSource; import io.fabric8.kubernetes.client.KubernetesClient; +import io.quarkus.arc.runtime.appcds.AppCDSRecorder; import io.quarkus.kubernetes.client.runtime.KubernetesClientBuildConfig; import io.quarkus.kubernetes.client.runtime.KubernetesClientUtils; import io.quarkus.runtime.TlsConfig; @@ -23,6 +26,12 @@ static class KubernetesConfigFactory implements ConfigurableConfigSourceFactory< @Override public Iterable getConfigSources(final ConfigSourceContext context, final KubernetesClientBuildConfig config) { + boolean inAppCDsGeneration = Boolean + .parseBoolean(System.getProperty(AppCDSRecorder.QUARKUS_APPCDS_GENERATE_PROP, "false")); + if (inAppCDsGeneration) { + return Collections.emptyList(); + } + // TODO - TlsConfig is used in a lot of place. This is to avoid having it to migrate to ConfigMapping. boolean trustAll = getImplicitConverter(Boolean.class) .convert(context.getValue("quarkus.tls.trust-all").getValue());