diff --git a/REFERENCE.md b/REFERENCE.md index e15eb41..dcc676e 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -77,7 +77,7 @@ The following parameters are available in the `opensearch` class: * [`use_default_jvm_gc_settings`](#-opensearch--use_default_jvm_gc_settings) * [`jvm_gc_settings`](#-opensearch--jvm_gc_settings) * [`default_jvm_gc_logging_settings`](#-opensearch--default_jvm_gc_logging_settings) -* [`use_defaultjvm_gc_logging_settings`](#-opensearch--use_defaultjvm_gc_logging_settings) +* [`use_default_jvm_gc_logging_settings`](#-opensearch--use_default_jvm_gc_logging_settings) * [`jvm_gc_logging_settings`](#-opensearch--jvm_gc_logging_settings) * [`manage_service`](#-opensearch--manage_service) * [`service_ensure`](#-opensearch--service_ensure) @@ -88,7 +88,6 @@ The following parameters are available in the `opensearch` class: * [`repository_ensure`](#-opensearch--repository_ensure) * [`repository_location`](#-opensearch--repository_location) * [`repository_gpg_key`](#-opensearch--repository_gpg_key) -* [`use_default_jvm_gc_logging_settings`](#-opensearch--use_default_jvm_gc_logging_settings) ##### `version` @@ -452,10 +451,14 @@ Default settings for jvm gc logging. Default value: `[]` -##### `use_defaultjvm_gc_logging_settings` +##### `use_default_jvm_gc_logging_settings` + +Data type: `Boolean` Whether to use the default jvm gc logging settings. +Default value: `true` + ##### `jvm_gc_logging_settings` Data type: `Array[String[1]]` @@ -536,11 +539,3 @@ Data type: `Stdlib::HTTPUrl` Default value: `'https://artifacts.opensearch.org/publickeys/opensearch.pgp'` -##### `use_default_jvm_gc_logging_settings` - -Data type: `Boolean` - - - -Default value: `true` - diff --git a/data/common.yaml b/data/common.yaml index f324aea..fdd67b5 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -678,14 +678,14 @@ opensearch::default_settings: - ".opensearch-observability" - ".opendistro-asynchronous-search-response*" - ".replication-metadata-store" -opensearch::jvm_gc_settings: +opensearch::default_jvm_gc_settings: - '8-10:-XX:+UseConcMarkSweepGC' - '8-10:-XX:CMSInitiatingOccupancyFraction=75' - '8-10:-XX:+UseCMSInitiatingOccupancyOnly' - '11-:-XX:+UseG1GC' - '11-:-XX:G1ReservePercent=25' - '11-:-XX:InitiatingHeapOccupancyPercent=30' -opensearch::jvm_gc_logging_settings: +opensearch::default_jvm_gc_logging_settings: - '8:-XX:+PrintGCDetails' - '8:-XX:+PrintGCDateStamps' - '8:-XX:+PrintTenuringDistribution' diff --git a/manifests/init.pp b/manifests/init.pp index 962e90a..885a7e6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -96,7 +96,7 @@ # User settings for jvm gc. # @param default_jvm_gc_logging_settings # Default settings for jvm gc logging. -# @param use_defaultjvm_gc_logging_settings +# @param use_default_jvm_gc_logging_settings # Whether to use the default jvm gc logging settings. # @param jvm_gc_logging_settings # User settings for jvm logging gc. diff --git a/spec/helper/get_defaults.rb b/spec/helper/get_defaults.rb index ad90ab3..edcde4d 100644 --- a/spec/helper/get_defaults.rb +++ b/spec/helper/get_defaults.rb @@ -72,48 +72,71 @@ def get_defaults(facts) ## ## version ## - 'version' => :undef, + 'version' => :undef, ## ## package values ## - 'manage_package' => true, - 'package_architecture' => package_architecture, - 'package_directory' => '/opt/opensearch', - 'package_ensure' => 'present', - 'package_provider' => package_provider, - 'package_source' => 'repository', - 'pin_package' => true, - 'apt_pin_priority' => 999, + 'manage_package' => true, + 'package_architecture' => package_architecture, + 'package_directory' => '/opt/opensearch', + 'package_ensure' => 'present', + 'package_provider' => package_provider, + 'package_source' => 'repository', + 'pin_package' => true, + 'apt_pin_priority' => 999, ## ## repository ## - 'manage_repository' => true, - 'repository_ensure' => 'present', - 'repository_location' => :undef, - 'repository_gpg_key' => 'https://artifacts.opensearch.org/publickeys/opensearch.pgp', + 'manage_repository' => true, + 'repository_ensure' => 'present', + 'repository_location' => :undef, + 'repository_gpg_key' => 'https://artifacts.opensearch.org/publickeys/opensearch.pgp', ## ## opensearch settings ## - 'manage_config' => true, - 'use_default_settings' => true, - 'default_settings' => default_settings, - 'settings' => {}, + 'manage_config' => true, + 'use_default_settings' => true, + 'default_settings' => default_settings, + 'settings' => {}, ## ## java settings ## - 'heap_size' => '512m', + 'heap_size' => '512m', + 'default_jvm_gc_settings' => [ + '8-10:-XX:+UseConcMarkSweepGC', + '8-10:-XX:CMSInitiatingOccupancyFraction=75', + '8-10:-XX:+UseCMSInitiatingOccupancyOnly', + '11-:-XX:+UseG1GC', + '11-:-XX:G1ReservePercent=25', + '11-:-XX:InitiatingHeapOccupancyPercent=30', + ], + 'use_default_jvm_gc_settings' => true, + 'jvm_gc_settings' => [], + 'default_jvm_gc_logging_settings' => [ + '8:-XX:+PrintGCDetails', + '8:-XX:+PrintGCDateStamps', + '8:-XX:+PrintTenuringDistribution', + '8:-XX:+PrintGCApplicationStoppedTime', + '8:-Xloggc:/var/log/opensearch/gc.log', + '8:-XX:+UseGCLogFileRotation', + '8:-XX:NumberOfGCLogFiles=32', + '8:-XX:GCLogFileSize=64m', + '9-:-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/opensearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m', + ], + 'use_default_jvm_gc_logging_settings' => true, + 'jvm_gc_logging_settings' => [], ## ## service values ## - 'manage_service' => true, - 'service_ensure' => 'running', - 'service_enable' => true, - 'restart_on_config_change' => true, - 'restart_on_package_change' => true, + 'manage_service' => true, + 'service_ensure' => 'running', + 'service_enable' => true, + 'restart_on_config_change' => true, + 'restart_on_package_change' => true, } end diff --git a/spec/shared_examples/config.rb b/spec/shared_examples/config.rb index 3a0c970..93d22ac 100644 --- a/spec/shared_examples/config.rb +++ b/spec/shared_examples/config.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -shared_examples 'config' do |parameter, _facts| +shared_examples 'config' do |parameter| it { is_expected.to contain_class('opensearch::config').that_comes_before('Class[opensearch::service]') } @@ -51,52 +51,23 @@ ) } - default_jvm_gc_settings = if parameter.key?('use_default_jvm_gc_settings') && parameter['use_default_jvm_gc_settings'] - [ - '8-10:-XX:+UseConcMarkSweepGC', - '8-10:-XX:CMSInitiatingOccupancyFraction=75', - '8-10:-XX:+UseCMSInitiatingOccupancyOnly', - '11-:-XX:+UseG1GC', - '11-:-XX:G1ReservePercent=25', - '11-:-XX:InitiatingHeapOccupancyPercent=30', - ] + default_jvm_gc_settings = if parameter['use_default_jvm_gc_settings'] + parameter['default_jvm_gc_settings'] else [] end - default_jvm_gc_logging_settings = if parameter.key?('use_default_jvm_gc_logging_settings') && parameter['use_default_jvm_gc_logging_settings'] - [ - '8:-XX:+PrintGCDetails', - '8:-XX:+PrintGCDateStamps', - '8:-XX:+PrintTenuringDistribution', - '8:-XX:+PrintGCApplicationStoppedTime', - '8:-Xloggc:/var/log/opensearch/gc.log', - '8:-XX:+UseGCLogFileRotation', - '8:-XX:NumberOfGCLogFiles=32', - '8:-XX:GCLogFileSize=64m', - '9-:-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/opensearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m', - ] + default_jvm_gc_logging_settings = if parameter['use_default_jvm_gc_logging_settings'] + parameter['default_jvm_gc_logging_settings'] else [] end - jvm_gc_settings = if parameter.key?('jvm_gc_settings') && parameter['jvm_gc_settings'] - parameter['jvm_gc_settings'] - else - [] - end - - jvm_gc_logging_settings = if parameter.key?('jvm_gc_logging_settings') && parameter['jvm_gc_logging_settings'] - parameter['jvm_gc_logging_settings'] - else - [] - end - [ default_jvm_gc_settings, default_jvm_gc_logging_settings, - jvm_gc_settings, - jvm_gc_logging_settings + parameter['jvm_gc_settings'], + parameter['jvm_gc_logging_settings'] ].flatten.each do |setting| match = setting.gsub(%r{([+*])}, '\\\\\\1')