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

Add ruby function to merge JVM options #23

Merged
merged 3 commits into from
Apr 10, 2020
Merged

Conversation

roborourke
Copy link
Contributor

Fixes #22

Right now using deep_merge results in the JVM options array being overwritten completely. The default options added since updating this module to use elasticstack and Java 11 result in the service not being able to start depending on the version of Elasticsearch selected.

This ensures that the default JVM options are scoped to the Java versions they work with and that any overrides do not cause these safe defaults to be overwritten completely unless it is intentional.

The update is backwards compatible with installations that set the -Xmx and -Xms JVM options using the legacy method and adds a new simpler option memory that will set these options for you.

Fixes #22

Right now using `deep_merge` results in the JVM options array being overwritten completely. The default options added since updating this module to use elasticstack and Java 11 result in the service not being able to start depending on the version of Elasticsearch selected.

This ensures that the default JVM options are scoped to the Java versions they work with and that any overrides do not cause these safe defaults to be overwritten completely unless it is intentional.

The update is backwards compatible with installations that set the `-Xmx` and `-Xms` JVM options using the legacy method and adds a new simpler option `memory` that will set these options for you.
@BronsonQuick
Copy link
Member

My first test with the following config failed:

extensions:
  - chassis/chassis_elasticsearch
elasticsearch:
  repo_version: 6.x
  version: 6.3.1
  plugins: [analysis-icu, ingest-attachment]
virtualbox:
  memory: 2048

The logs show that it's because of the following error:
Unrecognized VM option 'PrintGCDateStamps'

cat /etc/elasticsearch/es/jvm.options shows the following config:

# This file is managed by Puppet -- es
#
# Set the 'jvm_options' parameter on the elasticsearch class to change this file.

-Dfile.encoding=UTF-8
-Dio.netty.noKeySetOptimization=true
-Dio.netty.noUnsafe=true
-Dio.netty.recycler.maxCapacityPerThread=0
-Djava.awt.headless=true
-Djna.nosys=true
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-XX:+AlwaysPreTouch
-XX:+HeapDumpOnOutOfMemoryError
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+UseConcMarkSweepGC
-XX:+UseGCLogFileRotation
-XX:-OmitStackTraceInFastThrow
-XX:CMSInitiatingOccupancyFraction=75
-XX:GCLogFileSize=64m
-XX:NumberOfGCLogFiles=32
-Xloggc:/var/log/elasticsearch/es/gc.log
-Xms2g
-Xmx2g
-Xss1m
-server

@roborourke
Copy link
Contributor Author

Well that’s not right! From a clean install? I’ll try it again.

@BronsonQuick
Copy link
Member

Yeah that was from a fresh install and I also tried a provision as well. It was still getting the defaults from the ES puppet class.

The switch to using `include ::java` meant that the package declaration to remove it was declaring a duplicate resource. This just leaves Java installed instead as the main thing is that ES is removed.
@roborourke
Copy link
Contributor Author

Herp derp - if you passed no jvm_options it was matching all the defaults and stripping them out. I updated the function to allow all defaults if the passed options array is empty.

Tested and this works now with the following:

extensions:
  - chassis/chassis_elasticsearch
elasticsearch:
  repo_version: 6.x
  version: 6.3.1
  plugins: [analysis-icu, ingest-attachment]
virtualbox:
  memory: 2048

and

extensions:
  - chassis/chassis_elasticsearch
elasticsearch:
  repo_version: 6.x
  version: 6.3.1
  plugins: [analysis-icu, ingest-attachment]
  memory: 1024
virtualbox:
  memory: 2048

and

extensions:
  - chassis/chassis_elasticsearch
elasticsearch:
  jvm_options:
    - '-Xmx512m'
    - '-Xms512m'

@@ -11,9 +11,6 @@
class { 'elasticsearch':
ensure => 'absent'
}
package { 'java-common':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reference this was breaking using the disabled_extensions feature with this extension

Copy link
Member

Choose a reason for hiding this comment

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

Oohh let me dig into this one and open an issue to fix it! Thanks for letting me know!

Copy link
Member

@BronsonQuick BronsonQuick left a comment

Choose a reason for hiding this comment

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

Nice one! We're back in action now. Thank you Sir!

@BronsonQuick BronsonQuick merged commit 18097d3 into master Apr 10, 2020
@BronsonQuick BronsonQuick deleted the fix-jvm-option-defaults branch April 10, 2020 02:52
@BronsonQuick BronsonQuick restored the fix-jvm-option-defaults branch April 10, 2020 02:52
@roborourke roborourke deleted the fix-jvm-option-defaults branch May 22, 2020 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting JVM Options Prevents Elasticsearch from Loading
2 participants