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

Clarify behavior of custom launcher JVM opts #534

Merged
merged 1 commit into from
Mar 3, 2025

Conversation

pkoenig10
Copy link
Member

@pkoenig10 pkoenig10 commented Mar 3, 2025

The README suggests that JVM opts from launcher-custom.yml "override" JVM options from launcher-static.yml, but this is not the case. The JVM options are concatenated.

The only other modifications we make to the JVM options are for container support.

var combinedJvmOpts []string
combinedJvmOpts = append(combinedJvmOpts, staticConfig.JavaConfig.JvmOpts...)
combinedJvmOpts = append(combinedJvmOpts, customConfig.JvmOpts...)
jvmOpts := createJvmOpts(combinedJvmOpts, customConfig, logger)

func createJvmOpts(combinedJvmOpts []string, customConfig *CustomLauncherConfig, logger io.WriteCloser) []string {
if isEnvVarSet("CONTAINER") && !customConfig.DisableContainerSupport && !hasMaxRAMOverride(combinedJvmOpts) {
_, _ = fmt.Fprintln(logger, "Container support enabled")
jvmOptsWithUpdatedHeapSizeArgs, err := filterHeapSizeArgsV2(combinedJvmOpts)
if err != nil {
// When we fail to get the memory limit from the cgroups files, fallback to using percentage-based heap
// sizing. While this method doesn't take into account the per-processor memory offset, it is supported
// by all platforms using Java.
// Also, when the memory limit is unusually high (defined to be over 1TB), we revert to the
// percentage-based heap sizing. This is to handle the edge case where the cgroups memory limit is set
// to be an arbitrary large value.
combinedJvmOpts = filterHeapSizeArgs(combinedJvmOpts)
} else {
combinedJvmOpts = jvmOptsWithUpdatedHeapSizeArgs
}
return combinedJvmOpts
}
if isEnvVarSet("CONTAINER") {
if customConfig.DisableContainerSupport {
_, _ = fmt.Fprintln(logger, "Container support disabled in launcher-custom.yml")
} else if hasMaxRAMOverride(combinedJvmOpts) {
_, _ = fmt.Fprintln(logger, "Container support disabled: -XX:MaxRAM override present")
}
}
return combinedJvmOpts
}

@bulldozer-bot bulldozer-bot bot merged commit d0342d5 into develop Mar 3, 2025
8 checks passed
@bulldozer-bot bulldozer-bot bot deleted the pkoenig/readme branch March 3, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants