From 26420012f0ddcbd87aff714b4143377ccc5982dc Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Mon, 5 Sep 2022 17:45:44 +0300 Subject: [PATCH] fix (#24885) Do not infer command/args based on s2i image used --- .../openshift/deployment/OpenshiftProcessor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java b/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java index 56af46a290704..3017fc8d777ed 100644 --- a/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java +++ b/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java @@ -132,6 +132,9 @@ public void openshiftRequirementsJvm(OpenshiftConfig openshiftConfig, String baseJvmImage = config.baseJvmImage .orElse(OpenshiftConfig.getDefaultJvmImage(compiledJavaVersion.getJavaVersion())); + boolean hasCustomJarPath = config.jarFileName.isPresent() || config.jarDirectory.isPresent(); + boolean hasCustomJvmArguments = config.jvmArguments.isPresent(); + builderImageProducer.produce(new BaseImageInfoBuildItem(baseJvmImage)); Optional baseImage = OpenshiftBaseJavaImage.findMatching(baseJvmImage); @@ -150,8 +153,9 @@ public void openshiftRequirementsJvm(OpenshiftConfig openshiftConfig, envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJvmOptionsEnvVar(), String.join(" ", config.getEffectiveJvmArguments()), null)); }); + //In all other cases its the responsibility of the image to set those up correctly. - if (!baseImage.isPresent()) { + if (hasCustomJarPath || hasCustomJvmArguments) { List cmd = new ArrayList<>(); cmd.add("java"); cmd.addAll(config.getEffectiveJvmArguments()); @@ -180,6 +184,9 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig, String nativeBinaryFileName = null; + boolean hasCustomNativePath = config.nativeBinaryFileName.isPresent() || config.nativeBinaryDirectory.isPresent(); + boolean hasCustomNativeArguments = config.nativeArguments.isPresent(); + //The default openshift builder for native builds, renames the native binary. //To make things easier for the user, we need to handle it. if (usingDefaultBuilder && !config.nativeBinaryFileName.isPresent()) { @@ -195,6 +202,7 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig, // 1. explicitly specified by the user. // 2. detected via OpenshiftBaseNativeImage // 3. fallback value + String nativeBinaryDirectory = config.nativeBinaryDirectory .orElse(baseImage.map(i -> i.getNativeBinaryDirectory()).orElse(config.FALLBACK_NATIVE_BINARY_DIRECTORY)); String pathToNativeBinary = concatUnixPaths(nativeBinaryDirectory, nativeBinaryFileName); @@ -209,7 +217,7 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig, }); - if (!baseImage.isPresent() && config.nativeArguments.isPresent()) { + if (hasCustomNativePath || hasCustomNativeArguments) { commandProducer .produce(KubernetesCommandBuildItem.commandWithArgs(pathToNativeBinary, config.nativeArguments.get())); }