Skip to content

Commit

Permalink
allow configuring IMPORT_WORKERS_PERCENT
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Aug 22, 2023
1 parent c152fa0 commit b905b83
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@
# If activated, the distributions that are protected by a content guard will not be shown on the
# directory listing in the content app.
#
# @param import_workers_percent
# What percentage of available-workers will pulpcore use for import tasks at a time.
# By default, pulpcore will use all available workers.
#
# @example Default configuration
# include pulpcore
#
Expand Down Expand Up @@ -252,6 +256,7 @@
Hash[String[1], Pulpcore::Logger] $loggers = {},
Optional[Boolean] $telemetry = undef,
Optional[Boolean] $hide_guarded_distributions = undef,
Optional[Integer[1,100]] $import_workers_percent = undef,
) {
$settings_file = "${config_dir}/settings.py"
$certs_dir = "${config_dir}/certs"
Expand Down
34 changes: 34 additions & 0 deletions spec/acceptance/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,37 @@ class { 'pulpcore':
end
end
end

describe 'IMPORT_WORKERS_PERCENT setting' do
context 'default IMPORT_WORKERS_PERCENT' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include pulpcore
PUPPET
end
end

describe file('/etc/pulp/settings.py') do
it { is_expected.to be_file }
its(:content) { is_expected.to match(/^# IMPORT_WORKERS_PERCENT = 100$/) }
end
end

context 'IMPORT_WORKERS_PERCENT set' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
import_workers_percent => 42,
}
PUPPET
end
end

describe file('/etc/pulp/settings.py') do
it { is_expected.to be_file }
its(:content) { is_expected.to match(/^IMPORT_WORKERS_PERCENT = 42$/) }
end
end
end
6 changes: 6 additions & 0 deletions templates/settings.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ CACHE_SETTINGS = {
<% else -%>
HIDE_GUARDED_DISTRIBUTIONS = <%= scope.call_function('to_python', [scope['pulpcore::hide_guarded_distributions']]) %>
<% end -%>

<% if scope['pulpcore::import_workers_percent'].nil? -%>
# IMPORT_WORKERS_PERCENT = 100
<% else -%>
IMPORT_WORKERS_PERCENT = <%= scope['pulpcore::import_workers_percent'] %>
<% end -%>

0 comments on commit b905b83

Please sign in to comment.