Skip to content

Conversation

@patelsmit32123
Copy link
Contributor

Issues Resolved

Fixes #1106

Check List

  • Commits are signed per the DCO using --signoff
  • Unittest added for the new/changed functionality and all unit tests are successful
  • Customer-visible features documented
  • No linter warnings (make lint)

If CRDs are changed:

  • CRD YAMLs updated (make manifests) and also copied into the helm chart
  • Changes to CRDs documented

Please refer to the PR guidelines before submitting this pull request.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: patelsmit32123 <[email protected]>
@patelsmit32123 patelsmit32123 force-pushed the jvm-heap-size-settings branch from cdcef6d to 9f6753d Compare October 6, 2025 06:39
@patelsmit32123
Copy link
Contributor Author

@prudhvigodithi can you please review?

Comment on lines +448 to +456
func AppendJvmHeapSizeSettings(jvm string, heapSizeSettings string) string {
if strings.Contains(jvm, "Xms") || strings.Contains(jvm, "Xmx") {
return jvm
}
if jvm == "" {
return heapSizeSettings
}
return fmt.Sprintf("%s %s", jvm, heapSizeSettings)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patelsmit32123 This change works as expected. I tested it in my local lab.
Btw, I think this change causes the default heap size configuration to be ignored when either -Xms or -Xmx is already defined in JAVA_OPTS.

In other words, if a user sets a custom JAVA_OPTS containing -Xms or -Xmx, the operator won’t apply the default heap size anymore. That might be fine if intentional, but it also means users who only partially override Java options (e.g., setting -Xmx but not -Xms) will lose the default configuration for the missing value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, its intentional considering usually people provide both params

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patelsmit32123 it would be good to consider all cases.

@prudhvigodithi
Copy link
Member

Seeing the documentation https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/userguide/main.md

  • If jvm is not provided then the java heap size will be set to half of resources.requests.memory which is the recommend value for data nodes
  • If jvm is not provided and resources.requests.memory does not exist then value will be -Xmx512M -Xms512M.

We can leverage jvm only to control the -Xmx and -Xms values. For other settings we can jvmSettings or jvmOptions as new CRD? Then finally we can append all the values to a string.

@patelsmit32123 @josedev-union WDYT?

@prudhvigodithi prudhvigodithi self-assigned this Oct 21, 2025
@josedev-union
Copy link
Contributor

Seeing the documentation https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/userguide/main.md

  • If jvm is not provided then the java heap size will be set to half of resources.requests.memory which is the recommend value for data nodes
  • If jvm is not provided and resources.requests.memory does not exist then value will be -Xmx512M -Xms512M.

We can leverage jvm only to control the -Xmx and -Xms values. For other settings we can jvmSettings or jvmOptions as new CRD? Then finally we can append all the values to a string.

@patelsmit32123 @josedev-union WDYT?

@prudhvigodithi Thank you for the suggestion. With this new approach, we’ll need to clearly define which configuration should take precedence. In particular, if users already specify heap size options under jvmSettings/jvmOptions, how should that be reconciled with the proposed behavior?
From my perspective, introducing new fields in the CRD solely to control heap configuration might not be ideal, as it could increase complexity and redundancy.

@patelsmit32123
Copy link
Contributor Author

Seeing the documentation https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/userguide/main.md

  • If jvm is not provided then the java heap size will be set to half of resources.requests.memory which is the recommend value for data nodes
  • If jvm is not provided and resources.requests.memory does not exist then value will be -Xmx512M -Xms512M.

We can leverage jvm only to control the -Xmx and -Xms values. For other settings we can jvmSettings or jvmOptions as new CRD? Then finally we can append all the values to a string.
@patelsmit32123 @josedev-union WDYT?

@prudhvigodithi Thank you for the suggestion. With this new approach, we’ll need to clearly define which configuration should take precedence. In particular, if users already specify heap size options under jvmSettings/jvmOptions, how should that be reconciled with the proposed behavior? From my perspective, introducing new fields in the CRD solely to control heap configuration might not be ideal, as it could increase complexity and redundancy.

My opinion is also to not have multiple fields to handle jvm options. Also, there won't be any backward compatibility issues with approach of having just 1 field.

@patelsmit32123
Copy link
Contributor Author

@prudhvigodithi @josedev-union can we please finalize on the approach?

@devops-taehoon-kim
Copy link

devops-taehoon-kim commented Oct 28, 2025

After adding the jvm flag in our production Opensearch environment, the Heap setting was fixed to 1GB.

I suffered from this issue.

I'm glad it will be fix soon.

@synhershko synhershko merged commit 9b10349 into opensearch-project:main Oct 28, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in Engineering Effectiveness Board Oct 28, 2025
monotek pushed a commit to monotek/opensearch-k8s-operator that referenced this pull request Nov 4, 2025
### Issues Resolved
Fixes opensearch-project#1106

### Check List
- [ ] Commits are signed per the DCO using --signoff 
- [ ] Unittest added for the new/changed functionality and all unit
tests are successful
- [ ] Customer-visible features documented
- [ ] No linter warnings (`make lint`)

If CRDs are changed:
- [ ] CRD YAMLs updated (`make manifests`) and also copied into the helm
chart
- [ ] Changes to CRDs documented

Please refer to the [PR
guidelines](https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/developing.md#submitting-a-pr)
before submitting this pull request.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

Signed-off-by: patelsmit32123 <[email protected]>
joluc pushed a commit to joluc/opensearch-k8s-operator that referenced this pull request Nov 18, 2025
### Issues Resolved
Fixes opensearch-project#1106

### Check List
- [ ] Commits are signed per the DCO using --signoff 
- [ ] Unittest added for the new/changed functionality and all unit
tests are successful
- [ ] Customer-visible features documented
- [ ] No linter warnings (`make lint`)

If CRDs are changed:
- [ ] CRD YAMLs updated (`make manifests`) and also copied into the helm
chart
- [ ] Changes to CRDs documented

Please refer to the [PR
guidelines](https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/developing.md#submitting-a-pr)
before submitting this pull request.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

Signed-off-by: patelsmit32123 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[BUG] JVM heap size settings are not being set if other jvm settings are passed

5 participants