Skip to content

Commit 8dd44b4

Browse files
author
smasa90
committed
fix(compat): bare min. to get srv running on 7.x
Fixed jvm.options.erb to add required jvm options for 7.x Fixed jvm.options.erb to change jvm options required only for openjdk 8 Added ES_PATH_DIR instance environment var Fixed log4j2.properties.erb to fix Deprecation WARNINGS Keeped Backward Compatibility
1 parent dbd06d6 commit 8dd44b4

File tree

4 files changed

+49
-27
lines changed

4 files changed

+49
-27
lines changed

manifests/instance.pp

+7
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@
190190
false => undef,
191191
}
192192

193+
# Private var used by jvm.options.erb and log4j.properties.erb
194+
$_is_7_min = ( $::elasticsearch::version =~ String
195+
and versioncmp($::elasticsearch::version, '7.0.0') >= 0
196+
) or ( defined('$::elastic_stack::repo::version')
197+
and versioncmp(String($::elastic_stack::repo::version), '7') >= 0 )
198+
193199
if ($ensure == 'present') {
194200

195201
# Configuration hash
@@ -461,6 +467,7 @@
461467
$elasticsearch::init_defaults,
462468
{
463469
'CONF_DIR' => $configdir,
470+
'ES_PATH_DIR' => $configdir,
464471
'ES_HOME' => $elasticsearch::homedir,
465472
'ES_JVM_OPTIONS' => "${configdir}/jvm.options",
466473
'ES_PATH_CONF' => $configdir,

spec/defines/005_elasticsearch_instance_spec.rb

+15-14
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"elasticsearch/etc/init.d/elasticsearch.#{initscript}.erb",
8686
:init_defaults => {
8787
'CONF_DIR' => '/etc/elasticsearch/es-instance',
88+
'ES_PATH_DIR' => '/etc/elasticsearch/es-instance',
8889
'ES_PATH_CONF' => '/etc/elasticsearch/es-instance',
8990
'DATA_DIR' => '/var/lib/elasticsearch',
9091
'ES_JVM_OPTIONS' => '/etc/elasticsearch/es-instance/jvm.options',
@@ -799,21 +800,21 @@ class { 'elasticsearch':
799800
-Dlog4j2.disable.jmx=true.
800801
-XX:\+AlwaysPreTouch.
801802
-XX:\+HeapDumpOnOutOfMemoryError.
802-
-XX:\+PrintGCDateStamps.
803-
-XX:\+PrintGCDetails.
804-
-XX:\+PrintTenuringDistribution.
805803
-XX:\+UseCMSInitiatingOccupancyOnly.
806804
-XX:\+UseConcMarkSweepGC.
807-
-XX:\+UseGCLogFileRotation.
808805
-XX:-OmitStackTraceInFastThrow.
809806
-XX:CMSInitiatingOccupancyFraction=75.
810-
-XX:GCLogFileSize=64m.
811-
-XX:NumberOfGCLogFiles=32.
812-
-Xloggc:\/var\/log\/elasticsearch\/es-instance\/gc.log.
813807
-Xms4g.
814808
-Xmx4g.
815809
-Xss1m.
816810
-server.
811+
8:-XX:\+PrintGCDateStamps.
812+
8:-XX:\+PrintGCDetails.
813+
8:-XX:\+PrintTenuringDistribution.
814+
8:-XX:\+UseGCLogFileRotation.
815+
8:-XX:GCLogFileSize=64m.
816+
8:-XX:NumberOfGCLogFiles=32.
817+
8:-Xloggc:\/var\/log\/elasticsearch\/es-instance\/gc.log.
817818
}xm)
818819
end
819820
end
@@ -841,21 +842,21 @@ class { 'elasticsearch':
841842
-Dlog4j2.disable.jmx=true.
842843
-XX:\+AlwaysPreTouch.
843844
-XX:\+HeapDumpOnOutOfMemoryError.
844-
-XX:\+PrintGCDateStamps.
845-
-XX:\+PrintGCDetails.
846-
-XX:\+PrintTenuringDistribution.
847845
-XX:\+UseCMSInitiatingOccupancyOnly.
848846
-XX:\+UseConcMarkSweepGC.
849-
-XX:\+UseGCLogFileRotation.
850847
-XX:-OmitStackTraceInFastThrow.
851848
-XX:CMSInitiatingOccupancyFraction=75.
852-
-XX:GCLogFileSize=64m.
853-
-XX:NumberOfGCLogFiles=32.
854-
-Xloggc:\/var\/log\/elasticsearch\/es-instance\/gc.log.
855849
-Xms8g.
856850
-Xmx8g.
857851
-Xss1m.
858852
-server.
853+
8:-XX:\+PrintGCDateStamps.
854+
8:-XX:\+PrintGCDetails.
855+
8:-XX:\+PrintTenuringDistribution.
856+
8:-XX:\+UseGCLogFileRotation.
857+
8:-XX:GCLogFileSize=64m.
858+
8:-XX:NumberOfGCLogFiles=32.
859+
8:-Xloggc:\/var\/log\/elasticsearch\/es-instance\/gc.log.
859860
}xm)
860861
end
861862
end

templates/etc/elasticsearch/jvm.options.erb

+20-7
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,27 @@ defaults = {
2525
'-Dlog4j.shutdownHookEnabled' => '-Dlog4j.shutdownHookEnabled=false',
2626
'-Dlog4j2.disable.jmx' => '-Dlog4j2.disable.jmx=true',
2727
'HeapDumpOnOutOfMemoryError' => '-XX:+HeapDumpOnOutOfMemoryError',
28-
'PrintGCDetails' => '-XX:+PrintGCDetails',
29-
'PrintGCDateStamps' => '-XX:+PrintGCDateStamps',
30-
'PrintTenuringDistribution' => '-XX:+PrintTenuringDistribution',
31-
'Xloggc' => "-Xloggc:#{@logdir}/gc.log",
32-
'UseGCLogFileRotation' => '-XX:+UseGCLogFileRotation',
33-
'NumberOfGCLogFiles' => '-XX:NumberOfGCLogFiles=32',
34-
'GCLogFileSize' => '-XX:GCLogFileSize=64m',
28+
'PrintGCDetails' => '8:-XX:+PrintGCDetails',
29+
'PrintGCDateStamps' => '8:-XX:+PrintGCDateStamps',
30+
'PrintTenuringDistribution' => '8:-XX:+PrintTenuringDistribution',
31+
'Xloggc' => "8:-Xloggc:#{@logdir}/gc.log",
32+
'UseGCLogFileRotation' => '8:-XX:+UseGCLogFileRotation',
33+
'NumberOfGCLogFiles' => '8:-XX:NumberOfGCLogFiles=32',
34+
'GCLogFileSize' => '8:-XX:GCLogFileSize=64m',
3535
}
36+
defaults_7x = {
37+
'-Des.networkaddress.cache.ttl' => '-Des.networkaddress.cache.ttl=60',
38+
'-Des.networkaddress.cache.negative.ttl' => '-Des.networkaddress.cache.negative.ttl=10',
39+
'-Djava.io.tmpdir' => '-Djava.io.tmpdir=${ES_TMPDIR}',
40+
'HeapDumpPath' => '-XX:HeapDumpPath=/var/lib/elasticsearch',
41+
'ErrorFile' => "-XX:ErrorFile=#{@logdir}/hs_err_pid%p.log",
42+
'PrintGCApplicationStoppedTime' => '8:-XX:+PrintGCApplicationStoppedTime',
43+
'Xlog' => "9-:-Xlog:gc*,gc+age=trace,safepoint:file=#{@logdir}/gc.log:utctime,pid,tags:filecount=32,filesize=64m",
44+
'-Djava.locale.providers' => '9-:-Djava.locale.providers=COMPAT',
45+
}
46+
47+
if @_is_7_min then defaults.merge!( defaults_7x ) end
48+
3649
defaults.each {|k,v| set_default(@jvm_options, k, v)}
3750

3851
-%>

templates/etc/elasticsearch/log4j2.properties.erb

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<%- @node_marker = @_is_7_min ? '[%node_name]%marker' : '%marker' -%>
12
status = <%= @logging_level.downcase %>
23

34
# log action execution errors for easier debugging
@@ -7,20 +8,20 @@ logger.action.level = debug
78
appender.console.type = Console
89
appender.console.name = console
910
appender.console.layout.type = PatternLayout
10-
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
11+
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] <%= @node_marker %>%m%n
1112

1213
<%- if @file_rolling_type == 'file' -%>
1314
appender.fixed.type = File
1415
appender.fixed.name = fixed
1516
appender.fixed.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
1617
appender.fixed.layout.type = PatternLayout
17-
appender.fixed.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
18+
appender.fixed.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] <%= @node_marker %>%.-10000m%n
1819
<%- else -%>
1920
appender.rolling.type = RollingFile
2021
appender.rolling.name = rolling
2122
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
2223
appender.rolling.layout.type = PatternLayout
23-
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
24+
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] <%= @node_marker %>%.-10000m%n
2425
<%- if @file_rolling_type == 'dailyRollingFile' -%>
2526
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz
2627
appender.rolling.policies.type = Policies
@@ -49,7 +50,7 @@ appender.deprecation_rolling.type = RollingFile
4950
appender.deprecation_rolling.name = deprecation_rolling
5051
appender.deprecation_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation.log
5152
appender.deprecation_rolling.layout.type = PatternLayout
52-
appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
53+
appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] <%= @node_marker %>%.-10000m%n
5354
appender.deprecation_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation-%i.log.gz
5455
appender.deprecation_rolling.policies.type = Policies
5556
appender.deprecation_rolling.policies.size.type = SizeBasedTriggeringPolicy
@@ -70,7 +71,7 @@ appender.index_search_slowlog_rolling.type = RollingFile
7071
appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling
7172
appender.index_search_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog.log
7273
appender.index_search_slowlog_rolling.layout.type = PatternLayout
73-
appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
74+
appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] <%= @node_marker %>%.-10000m%n
7475
appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog-%d{yyyy-MM-dd}.log
7576
appender.index_search_slowlog_rolling.policies.type = Policies
7677
appender.index_search_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy
@@ -86,7 +87,7 @@ appender.index_indexing_slowlog_rolling.type = RollingFile
8687
appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling
8788
appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog.log
8889
appender.index_indexing_slowlog_rolling.layout.type = PatternLayout
89-
appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
90+
appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] <%= @node_marker %>%.-10000m%n
9091
appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog-%d{yyyy-MM-dd}.log
9192
appender.index_indexing_slowlog_rolling.policies.type = Policies
9293
appender.index_indexing_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy

0 commit comments

Comments
 (0)