Skip to content

Commit

Permalink
Fixes #32891 - Add feature to optionally enable new tasking system
Browse files Browse the repository at this point in the history
This introduces a new parameter `use_rq_tasking_system` with default
value true that configures pulpcore to use the same rq worker tasking
system as before. When false, it instead configures pulpcore to use
the newer postgresql tasking system introduced in pulpcore version 3.13.
Acceptance tests are included to ensure users can switch between either
worker type.
  • Loading branch information
wbclark committed Jun 28, 2021
1 parent a9bc811 commit 1027dbf
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 0 deletions.
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
# available, likely results in performance degradation due to I/O blocking and is not recommended in most cases. Modifying this parameter should
# be done incrementally with benchmarking at each step to determine an optimal value for your deployment.
#
# @param use_rq_tasking_system
# Use the older rq workers tasking system instead of the newer postgresql tasking system introduced in Pulpcore 3.13.
# Any benchmarking you did to optimize worker_count or other tasking related parameters will no longer be accurate after changing the tasking system.
# Do not modify this setting unless you understand the implications for performance and stability.
#
# @param service_enable
# Enable/disable Pulp services at boot.
#
Expand Down Expand Up @@ -197,6 +202,7 @@
Pulpcore::ChecksumTypes $allowed_content_checksums = ['sha224', 'sha256', 'sha384', 'sha512'],
String[1] $remote_user_environ_name = 'HTTP_REMOTE_USER',
Integer[0] $worker_count = min(8, $facts['processors']['count']),
Boolean $use_rq_tasking_system = true,
Boolean $service_enable = true,
Boolean $service_ensure = true,
Integer[0] $content_service_worker_count = (2*min(8, $facts['processors']['count']) + 1),
Expand Down
129 changes: 129 additions & 0 deletions spec/acceptance/disable_new_tasking_system_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
require 'spec_helper_acceptance'

describe 'initial configuration with newer postgresql tasking system' do
certdir = '/etc/pulpcore-certs'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_rq_tasking_system => false,
}
PUPPET
end
end

describe service('httpd') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-api') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-content') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-resource-manager') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-worker@1') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe port(80) do
it { is_expected.to be_listening }
end

describe port(443) do
it { is_expected.to be_listening }
end

describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do
its(:response_code) { is_expected.to eq(200) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") do
its(:stdout) { is_expected.to match(/^USE_NEW_WORKER_TYPE = True/) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig") do
its(:stdout) { is_expected.to match(/^0 workers, /) }
its(:stdout) { is_expected.not_to match(/^resource-manager /) }
its(:exit_status) { is_expected.to eq 0 }
end
end

describe 'reconfigure pulpcore to use older rq worker tasking system' do
certdir = '/etc/pulpcore-certs'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_rq_tasking_system => true,
}
PUPPET
end
end

describe service('httpd') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-api') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-content') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-resource-manager') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-worker@1') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe port(80) do
it { is_expected.to be_listening }
end

describe port(443) do
it { is_expected.to be_listening }
end

describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do
its(:response_code) { is_expected.to eq(200) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") do
its(:stdout) { is_expected.to match(/^USE_NEW_WORKER_TYPE = False/) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig") do
its(:stdout) { is_expected.to match(/^2 workers, /) }
its(:stdout) { is_expected.to match(/^resource-manager /) }
its(:exit_status) { is_expected.to eq 0 }
end
end
129 changes: 129 additions & 0 deletions spec/acceptance/enable_new_tasking_system_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
require 'spec_helper_acceptance'

describe 'initial configuration with older rq worker tasking system' do
certdir = '/etc/pulpcore-certs'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_rq_tasking_system => true,
}
PUPPET
end
end

describe service('httpd') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-api') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-content') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-resource-manager') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-worker@1') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe port(80) do
it { is_expected.to be_listening }
end

describe port(443) do
it { is_expected.to be_listening }
end

describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do
its(:response_code) { is_expected.to eq(200) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") do
its(:stdout) { is_expected.to match(/^USE_NEW_WORKER_TYPE = False/) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig") do
its(:stdout) { is_expected.to match(/^2 workers, /) }
its(:stdout) { is_expected.to match(/^resource-manager /) }
its(:exit_status) { is_expected.to eq 0 }
end
end

describe 'reconfigure pulpcore to use newer postgresql tasking system' do
certdir = '/etc/pulpcore-certs'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_rq_tasking_system => false,
}
PUPPET
end
end

describe service('httpd') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-api') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-content') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-resource-manager') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-worker@1') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe port(80) do
it { is_expected.to be_listening }
end

describe port(443) do
it { is_expected.to be_listening }
end

describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do
its(:response_code) { is_expected.to eq(200) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") do
its(:stdout) { is_expected.to match(/^USE_NEW_WORKER_TYPE = True/) }
its(:exit_status) { is_expected.to eq 0 }
end

describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig") do
its(:stdout) { is_expected.to match(/^0 workers, /) }
its(:stdout) { is_expected.not_to match(/^resource-manager /) }
its(:exit_status) { is_expected.to eq 0 }
end
end
2 changes: 2 additions & 0 deletions templates/settings.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ REDIS_HOST = "localhost"
REDIS_PORT = "<%= scope['redis::port'] %>"
REDIS_DB = <%= scope['pulpcore::redis_db'] %>

USE_NEW_WORKER_TYPE=<%= scope['pulpcore::use_rq_tasking_system'] ? "False" : "True" %>

MEDIA_ROOT = "<%= scope['pulpcore::media_root'] %>"
STATIC_ROOT = "<%= scope['pulpcore::static_root'] %>"
STATIC_URL = "<%= scope['pulpcore::static_url'] %>"
Expand Down

0 comments on commit 1027dbf

Please sign in to comment.