Skip to content

Commit

Permalink
Fixes #33214: Set minimum Puma threads equal to maximum puma threads …
Browse files Browse the repository at this point in the history
…by default

This has been shown to prevent memory leaks that can appear in Foreman
when running under Puma. This only changes the default to match and
users must still be aware of this potential when changing the tunings.
  • Loading branch information
ehelms committed Aug 9, 2021
1 parent 24ca255 commit 6945ee1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
content => template('foreman/database.yml.erb'),
}

$min_puma_threads = pick($foreman::foreman_service_puma_threads_min, $foreman::foreman_service_puma_threads_max)
systemd::dropin_file { 'foreman-service':
filename => 'installer.conf',
unit => "${foreman::foreman_service}.service",
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
Optional[Redis::RedisUrl] $dynflow_redis_url = $foreman::params::dynflow_redis_url,
Boolean $hsts_enabled = $foreman::params::hsts_enabled,
Array[Stdlib::HTTPUrl] $cors_domains = $foreman::params::cors_domains,
Integer[0] $foreman_service_puma_threads_min = $foreman::params::foreman_service_puma_threads_min,
Optional[Integer[0]] $foreman_service_puma_threads_min = $foreman::params::foreman_service_puma_threads_min,
Integer[0] $foreman_service_puma_threads_max = $foreman::params::foreman_service_puma_threads_max,
Integer[0] $foreman_service_puma_workers = $foreman::params::foreman_service_puma_workers,
Hash[String, Any] $rails_cache_store = $foreman::params::rails_cache_store,
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
$foreman_service = 'foreman'
$foreman_service_ensure = 'running'
$foreman_service_enable = true
$foreman_service_puma_threads_min = 0
$foreman_service_puma_threads_min = undef
$foreman_service_puma_threads_max = 16
$foreman_service_puma_workers = 2

Expand Down
13 changes: 12 additions & 1 deletion spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,18 @@
.with_content(/^SocketUser=#{apache_user}$/)
end

it { should contain_systemd__dropin_file('foreman-service').with_filename('installer.conf').with_unit('foreman.service') }
it 'overrides foreman.service systemd service' do
should contain_systemd__dropin_file('foreman-service')
.with_ensure('present')
.with_filename('installer.conf')
.with_unit('foreman.service')
.with_content(%r{^User=foreman$})
.with_content(%r{^Environment=FOREMAN_ENV=production$})
.with_content(%r{^Environment=FOREMAN_HOME=/usr/share/foreman$})
.with_content(%r{^Environment=FOREMAN_PUMA_THREADS_MIN=16$})
.with_content(%r{^Environment=FOREMAN_PUMA_THREADS_MAX=16$})
.with_content(%r{^Environment=FOREMAN_PUMA_WORKERS=2$})
end

it { should contain_apache__vhost('foreman').without_custom_fragment(/Alias/) }

Expand Down
2 changes: 1 addition & 1 deletion templates/foreman.service-overrides.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
User=<%= scope['foreman::user'] %>
Environment=FOREMAN_ENV=<%= scope['foreman::rails_env'] %>
Environment=FOREMAN_HOME=<%= scope['foreman::app_root'] %>
Environment=FOREMAN_PUMA_THREADS_MIN=<%= scope['foreman::foreman_service_puma_threads_min'] %>
Environment=FOREMAN_PUMA_THREADS_MIN=<%= @min_puma_threads %>
Environment=FOREMAN_PUMA_THREADS_MAX=<%= scope['foreman::foreman_service_puma_threads_max'] %>
Environment=FOREMAN_PUMA_WORKERS=<%= scope['foreman::foreman_service_puma_workers'] %>

0 comments on commit 6945ee1

Please sign in to comment.