Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistency in kubernetes commands / arguments handling between jvm and native #27733

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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