Set default elasticsearch heap size to 2GB (Alternate PR) by aidando73 · Pull Request #5684 · testcontainers/testcontainers-java (original) (raw)
Proposed fix for issue #5393. Thought I could help to address comments from @DKarim 's PR #5398 as it looks like he is busy (hope I am not intruding with this PR @DKarim). Had some additional improvements I wanted to make as well.
Rationale behind changes
Decided against the additional method that @DKarim introduced. I think it's better to introduce additional public api in a separate issue that way we can determine if there's a real demand for it otherwise we'd be adding extra complexity and maintenance burden for little gain.
Also opted for usage of the /usr/share/elasticsearch/config/jvm.options.d/ folder over the ES_JAVA_OPTS environment variable. For a few reasons:
- Elasticsearch 8 seems to have renamed
ES_JAVA_OPTStoCLI_JAVA_OPTSon their docs https://www.elastic.co/guide/en/elasticsearch/reference/current/advanced-configuration.html. After testing, it seems like they have backwards compatibility forES_JAVA_OPTS- but usage of both at the same time is unpredictable. - The previous approach overrides all user defined jvm options in
/usr/share/elasticsearch/config/jvm.options.d/, thus if any user had memory defined in one of these files then the default would have overwritten it:
The ES_JAVA_OPTS variable overrides all other JVM options.