Skip to content

Commit

Permalink
Merge pull request quarkusio#27733 from iocanel/issue-24885-smart-args
Browse files Browse the repository at this point in the history
Fix inconsistency in kubernetes commands / arguments handling between jvm and native
  • Loading branch information
iocanel authored Sep 12, 2022
2 parents a89179c + 2642001 commit f4238ad
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<OpenshiftBaseJavaImage> baseImage = OpenshiftBaseJavaImage.findMatching(baseJvmImage);

Expand All @@ -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<String> cmd = new ArrayList<>();
cmd.add("java");
cmd.addAll(config.getEffectiveJvmArguments());
Expand Down Expand Up @@ -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()) {
Expand All @@ -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);
Expand All @@ -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()));
}
Expand Down

0 comments on commit f4238ad

Please sign in to comment.