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 max_open_files parameter for systemd systems #298

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

assert_private()

$max_open_files = $prometheus::max_open_files

if $prometheus::server::init_style {
if( versioncmp($prometheus::server::version, '2.0.0') < 0 ){
# helper variable indicating prometheus version, so we can use on this information in the template
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@
# creating the appropriate prometheus scrape configs for each endpoint. All scrape_config
# options can be passed as hash elements. Only the job_name is mandatory.
#
# [*max_open_files*]
# The maximum number of file descriptors for the prometheus server.
# Defaults to `undef`, but set to a large integer to override your default OS limit.
# Currently only implemented for systemd based service.
#
# Actions:
#
# Requires: see Modulefile
Expand Down Expand Up @@ -194,6 +199,7 @@
String $os = downcase($facts['kernel']),
Optional[Variant[Stdlib::HTTPUrl, Stdlib::Unixpath, String[1]]] $external_url = undef,
Optional[Array[Hash[String[1], Any]]] $collect_scrape_jobs = [],
Optional[Integer] $max_open_files = undef,
Copy link
Member

Choose a reason for hiding this comment

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

@alexjfisher Could you please fix the indentation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't think adding 45 extra whitespaces improved readability.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rebased (which added the collect_scrape_jobs line above mine)

) {

case $arch {
Expand Down
18 changes: 18 additions & 0 deletions spec/classes/prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@
'content' => File.read(fixtures('files', "prometheus#{prom_major}.systemd"))
)
}
describe 'max_open_files' do
context 'by default' do
it {
content = catalogue.resource('systemd::unit_file', 'prometheus.service').send(:parameters)[:content]
expect(content).not_to include('LimitNOFILE')
}
end
context 'when set to 1000000' do
let(:params) do
parameters.merge('max_open_files' => 1_000_000)
end

it {
content = catalogue.resource('systemd::unit_file', 'prometheus.service').send(:parameters)[:content]
expect(content).to include('LimitNOFILE=1000000')
}
end
end
elsif ['ubuntu-14.04-x86_64'].include?(os)
# init_style = 'upstart'

Expand Down
3 changes: 3 additions & 0 deletions templates/prometheus.systemd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ ExecStart=<%= scope.lookupvar('prometheus::server::bin_dir') %>/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
<% if @max_open_files -%>
LimitNOFILE=<%= @max_open_files %>
<% end -%>

[Install]
WantedBy=multi-user.target