Skip to content

Commit

Permalink
Add support for managing jetty threads
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak authored and ekohl committed Nov 13, 2018
1 parent 2553ffa commit c95e761
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
31 changes: 31 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,32 @@
# $server_parser:: Sets the parser to use. Valid options are 'current' or 'future'.
# Defaults to 'current'.
#
# $server_acceptor_threads:: This sets the number of threads that the webserver will dedicate to accepting
# socket connections for unencrypted HTTP traffic. If not provided, the webserver
# defaults to the number of virtual cores on the host divided by 8, with a minimum
# of 1 and maximum of 4.
#
# $server_selector_threads:: This sets the number of selectors that the webserver will dedicate to processing
# events on connected sockets for unencrypted HTTPS traffic. If not provided,
# the webserver defaults to the minimum of: virtual cores on the host divided by 2
# or max-threads divided by 16, with a minimum of 1.
#
# $server_max_threads:: This sets the maximum number of threads assigned to responding to HTTP and/or
# HTTPS requests for a single webserver, effectively changing how many
# concurrent requests can be made at one time. If not provided, the
# webserver defaults to 200.
#
# $server_ssl_acceptor_threads:: This sets the number of threads that the webserver will dedicate to accepting
# socket connections for encrypted HTTPS traffic. If not provided, defaults to
# the number of virtual cores on the host divided by 8, with a minimum of 1 and maximum of 4.
#
# $server_ssl_selector_threads:: This sets the number of selectors that the webserver will dedicate to processing
# events on connected sockets for encrypted HTTPS traffic. Defaults to the number of
# virtual cores on the host divided by 2, with a minimum of 1 and maximum of 4.
# The number of selector threads actually used by Jetty is twice the number of selectors
# requested. For example, if a value of 3 is specified for the ssl-selector-threads setting,
# Jetty will actually use 6 selector threads.
#
# === Usage:
#
# * Simple usage:
Expand Down Expand Up @@ -735,6 +761,11 @@
Boolean $server_puppetserver_experimental = $puppet::params::server_puppetserver_experimental,
Array[String] $server_puppetserver_trusted_agents = $puppet::params::server_puppetserver_trusted_agents,
Optional[Enum['off', 'jit', 'force']] $server_compile_mode = $puppet::params::server_compile_mode,
Optional[Integer[1]] $server_acceptor_threads = undef,
Optional[Integer[1]] $server_selector_threads = undef,
Optional[Integer[1]] $server_ssl_acceptor_threads = undef,
Optional[Integer[1]] $server_ssl_selector_threads = undef,
Optional[Integer[1]] $server_max_threads = undef,
) inherits puppet::params {
contain puppet::config

Expand Down
5 changes: 5 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@
Boolean $puppetserver_experimental = $::puppet::server_puppetserver_experimental,
Array[String] $puppetserver_trusted_agents = $::puppet::server_puppetserver_trusted_agents,
Optional[Enum['off', 'jit', 'force']] $compile_mode = $::puppet::server_compile_mode,
Optional[Integer[1]] $selector_threads = $::puppet::server_selector_threads,
Optional[Integer[1]] $acceptor_threads = $::puppet::server_acceptor_threads,
Optional[Integer[1]] $ssl_selector_threads = $::puppet::server_ssl_selector_threads,
Optional[Integer[1]] $ssl_acceptor_threads = $::puppet::server_ssl_acceptor_threads,
Optional[Integer[1]] $max_threads = $::puppet::server_max_threads,
) {
if $implementation == 'master' and $ip != $puppet::params::ip {
notify {
Expand Down
5 changes: 5 additions & 0 deletions manifests/server/puppetserver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
$server_trusted_agents = $::puppet::server::puppetserver_trusted_agents,
$allow_header_cert_info = $::puppet::server::allow_header_cert_info,
$compile_mode = $::puppet::server::compile_mode,
$acceptor_threads = $::puppet::server::acceptor_threads,
$selector_threads = $::puppet::server::selector_threads,
$ssl_acceptor_threads = $::puppet::server::ssl_acceptor_threads,
$ssl_selector_threads = $::puppet::server::ssl_selector_threads,
$max_threads = $::puppet::server::max_threads,
) {
include ::puppet::server

Expand Down
28 changes: 28 additions & 0 deletions spec/classes/puppet_server_puppetserver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
.with_content(/ssl-port:\s8140/)
.without_content(/ host:\s/)
.without_content(/ port:\s8139/)
.without_content(/selector-threads:/)
.without_content(/acceptor-threads:/)
.without_content(/ssl-selector-threads:/)
.without_content(/ssl-acceptor-threads:/)
.without_content(/max-threads:/)
}
it {
should contain_file(auth_conf)
Expand Down Expand Up @@ -586,6 +591,29 @@
let(:params) { super().merge(server_puppetserver_version: '2.1.0') }
it { should raise_error(Puppet::Error, /puppetserver <2.2 is not supported by this module version/) }
end

describe 'allow jetty specific server threads' do
context 'with thread config' do
let(:params) do
super().merge(
server_selector_threads: 1,
server_acceptor_threads: 2,
server_ssl_selector_threads: 3,
server_ssl_acceptor_threads: 4,
server_max_threads: 5
)
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/selector-threads: 1/).
with_content(/acceptor-threads: 2/).
with_content(/ssl-selector-threads: 3/).
with_content(/ssl-acceptor-threads: 4/).
with_content(/max-threads: 5/)
}
end
end
end
end
end
15 changes: 15 additions & 0 deletions templates/server/puppetserver/conf.d/webserver.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ webserver: {
<%= cipher_suite %>,
<%- end -%>
]
<%- if @acceptor_threads -%>
acceptor-threads: <%= @acceptor_threads %>
<%- end -%>
<%- if @selector_threads -%>
selector-threads: <%= @selector_threads %>
<%- end -%>
<%- if @ssl_acceptor_threads -%>
ssl-acceptor-threads: <%= @ssl_acceptor_threads %>
<%- end -%>
<%- if @ssl_selector_threads -%>
ssl-selector-threads: <%= @ssl_selector_threads %>
<%- end -%>
<%- if @max_threads -%>
max-threads: <%= @max_threads %>
<%- end -%>
}

0 comments on commit c95e761

Please sign in to comment.