From 4c213c8c74a209316c0536e9845949c8e44e33d0 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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 56af46a2907042..37d101385d1977 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,14 +153,15 @@ 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()); cmd.addAll(Arrays.asList("-jar", pathToJar)); envProducer.produce(KubernetesEnvBuildItem.createSimpleVar("JAVA_APP_JAR", pathToJar, null)); - commandProducer.produce(KubernetesCommandBuildItem.command(cmd)); + commandProducer.produce(new KubernetesCommandBuildItem(cmd, config.jvmArguments.get())); } } } @@ -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())); }