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_legacy_tasking_system` which
defaults to true and configures the application the same as before.
When set to false, pulpcore is configured with the new tasking system
instead. Acceptance tests are included to ensure that users can switch
between the two tasking systems. This is backwards compatible with
Pulpcore versions older than 3.13 ONLY when configured to use the
legacy tasking system. The newer tasking system requires Pulpcore
version >= 3.13.
  • Loading branch information
wbclark committed Jun 27, 2021
1 parent 714e187 commit 8e3dd6a
Show file tree
Hide file tree
Showing 6 changed files with 305 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_legacy_tasking_system
# Use the legacy tasking system with RQ workers instead of the newer tasking system. Do not modify this setting unless you understand the implications for
# performance and stability. Note that any benchmarking you did to find an optimal value of the worker_count parameter will no longer be applicable if you
# change the configured tasking system. The newer tasking system is only supported for Pulpcore releases >= 3.13.
#
# @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_legacy_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
139 changes: 139 additions & 0 deletions spec/acceptance/disable_new_tasking_system_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
require 'spec_helper_acceptance'

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

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_legacy_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

describe command("ps -e -o command") do
its(:stdout) { is_expected.to match(%r(^/usr/libexec/pulpcore/pulpcore-worker$)) }
its(:stdout) { is_expected.to match(%r(^/usr/libexec/pulpcore/pulpcore-worker --resource-manager$)) }
its(:exit_status) { is_expected.to eq 0 }
end
end

describe 'disable new tasking system' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_legacy_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

describe command("ps -e -o command") do
its(:stdout) { is_expected.not_to match(%r(^/usr/libexec/pulpcore/pulpcore-worker$)) }
its(:stdout) { is_expected.not_to match(%r(^/usr/libexec/pulpcore/pulpcore-worker --resource-manager$)) }
its(:exit_status) { is_expected.to eq 0 }
end
end
139 changes: 139 additions & 0 deletions spec/acceptance/enable_new_tasking_system_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
require 'spec_helper_acceptance'

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

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_legacy_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

describe command("ps -e -o command") do
its(:stdout) { is_expected.not_to match(%r(^/usr/libexec/pulpcore/pulpcore-worker$)) }
its(:stdout) { is_expected.not_to match(%r(^/usr/libexec/pulpcore/pulpcore-worker --resource-manager$)) }
its(:exit_status) { is_expected.to eq 0 }
end
end

describe 'enable new tasking system' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
use_legacy_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

describe command("ps -e -o command") do
its(:stdout) { is_expected.to match(%r(^/usr/libexec/pulpcore/pulpcore-worker$)) }
its(:stdout) { is_expected.to match(%r(^/usr/libexec/pulpcore/pulpcore-worker --resource-manager$)) }
its(:exit_status) { is_expected.to eq 0 }
end
end
4 changes: 4 additions & 0 deletions templates/pulpcore-resource-manager.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ User=<%= scope['pulpcore::user'] %>
Group=<%= scope['pulpcore::group'] %>
WorkingDirectory=<%= scope['pulpcore::user_home'] %>
RuntimeDirectory=pulpcore-resource-manager
<% if scope['pulpcore::use_legacy_tasking_system'] %>
ExecStart=/usr/libexec/pulpcore/rq worker \
-w pulpcore.tasking.worker.PulpWorker -n resource-manager \
-c 'pulpcore.rqconfig' \
--disable-job-desc-logging
<% else %>
ExecStart=/usr/libexec/pulpcore/pulpcore-worker --resource-manager
<% end %>

SyslogIdentifier=pulpcore-resource-manager

Expand Down
8 changes: 8 additions & 0 deletions templates/[email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[Unit]
<% if scope['pulpcore::use_legacy_tasking_system'] %>
Description=Pulp RQ Worker
<% else %>
Description=Pulp Worker
<% end %>
After=network-online.target
Wants=network-online.target

Expand All @@ -13,10 +17,14 @@ User=<%= scope['pulpcore::user'] %>
Group=<%= scope['pulpcore::group'] %>
WorkingDirectory=<%= scope['pulpcore::user_home'] %>
RuntimeDirectory=pulpcore-worker-%i
<% if scope['pulpcore::use_legacy_tasking_system'] %>
ExecStart=/usr/libexec/pulpcore/rq worker \
-w pulpcore.tasking.worker.PulpWorker \
-c 'pulpcore.rqconfig' \
--disable-job-desc-logging
<% else %>
ExecStart=/usr/libexec/pulpcore/pulpcore-worker
<% end %>

SyslogIdentifier=pulpcore-worker-%i

Expand Down
9 changes: 9 additions & 0 deletions templates/settings.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = (
ALLOWED_IMPORT_PATHS = <%= scope['pulpcore::allowed_import_path'] %>
ALLOWED_EXPORT_PATHS = <%= scope['pulpcore::allowed_export_path'] %>
ALLOWED_CONTENT_CHECKSUMS = <%= scope['pulpcore::allowed_content_checksums'] %>
<% if scope['pulpcore::use_legacy_tasking_system'] %>

# This setting is necessary but not sufficient to use the new tasking system;
# the systemd unit files must also be properly configured for either worker type.
# As such you should NEVER directly modify this setting. Refer to the documentation
# (from your software vendor, if any, otherwise to the community documentation) for
# the correct procedure to change between the new and legacy worker types.
USER_NEW_WORKER_TYPE=True
<% end %>

# Derive HTTP/HTTPS via the X-Forwarded-Proto header set by Apache
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

0 comments on commit 8e3dd6a

Please sign in to comment.