From e9424f9c1679c9099d7ca15be083bd32e0bbccc9 Mon Sep 17 00:00:00 2001 From: William Bradford Clark Date: Tue, 6 Jul 2021 11:44:37 -0400 Subject: [PATCH] Disable and remove pulpcore-resource-manager.service when not using RQ tasking --- manifests/service.pp | 16 ++++++++++++---- spec/acceptance/basic_spec.rb | 8 ++++---- .../disable_new_tasking_system_spec.rb | 12 ++++++++++-- .../acceptance/enable_new_tasking_system_spec.rb | 12 ++++++++++-- spec/acceptance/plugins_spec.rb | 4 ++-- spec/acceptance/use_pulp2_content_route_spec.rb | 4 ++-- spec/classes/pulpcore_spec.rb | 2 +- templates/settings.py.erb | 8 ++++++++ 8 files changed, 49 insertions(+), 17 deletions(-) diff --git a/manifests/service.pp b/manifests/service.pp index d07aa05d..8861f7ed 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -18,10 +18,18 @@ service_content => template('pulpcore/pulpcore-content.service.erb'), } - systemd::unit_file { 'pulpcore-resource-manager.service': - content => template('pulpcore/pulpcore-resource-manager.service.erb'), - active => $pulpcore::service_ensure, - enable => $pulpcore::service_enable, + if $pulpcore::use_rq_tasking_system { + systemd::unit_file { 'pulpcore-resource-manager.service': + content => template('pulpcore/pulpcore-resource-manager.service.erb'), + active => $pulpcore::service_ensure, + enable => $pulpcore::service_enable, + } + } else { + systemd::unit_file { 'pulpcore-resource-manager.service': + ensure => 'absent', + active => false, + enable => false, + } } systemd::unit_file { 'pulpcore-worker@.service': diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 845373b3..0a44eb3c 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -29,8 +29,8 @@ class { 'pulpcore': end describe service('pulpcore-resource-manager') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } + it { is_expected.not_to be_enabled } + it { is_expected.not_to be_running } end describe service('pulpcore-worker@1') do @@ -113,8 +113,8 @@ class { 'pulpcore': end describe service('pulpcore-resource-manager') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } + it { is_expected.not_to be_enabled } + it { is_expected.not_to be_running } end describe service('pulpcore-worker@1') do diff --git a/spec/acceptance/disable_new_tasking_system_spec.rb b/spec/acceptance/disable_new_tasking_system_spec.rb index da5614eb..f6932860 100644 --- a/spec/acceptance/disable_new_tasking_system_spec.rb +++ b/spec/acceptance/disable_new_tasking_system_spec.rb @@ -29,9 +29,13 @@ class { 'pulpcore': it { is_expected.to be_running } end + describe file('/etc/systemd/system/pulpcore-resource-manager.service') do + it { is_expected.not_to exist } + end + describe service('pulpcore-resource-manager') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } + it { is_expected.not_to be_enabled } + it { is_expected.not_to be_running } end describe service('pulpcore-worker@1') do @@ -93,6 +97,10 @@ class { 'pulpcore': it { is_expected.to be_running } end + describe file('/etc/systemd/system/pulpcore-resource-manager.service') do + it { is_expected.to exist } + end + describe service('pulpcore-resource-manager') do it { is_expected.to be_enabled } it { is_expected.to be_running } diff --git a/spec/acceptance/enable_new_tasking_system_spec.rb b/spec/acceptance/enable_new_tasking_system_spec.rb index 6ed9731d..d14cec69 100644 --- a/spec/acceptance/enable_new_tasking_system_spec.rb +++ b/spec/acceptance/enable_new_tasking_system_spec.rb @@ -29,6 +29,10 @@ class { 'pulpcore': it { is_expected.to be_running } end + describe file('/etc/systemd/system/pulpcore-resource-manager.service') do + it { is_expected.to exist } + end + describe service('pulpcore-resource-manager') do it { is_expected.to be_enabled } it { is_expected.to be_running } @@ -93,9 +97,13 @@ class { 'pulpcore': it { is_expected.to be_running } end + describe file('/etc/systemd/system/pulpcore-resource-manager.service') do + it { is_expected.not_to exist } + end + describe service('pulpcore-resource-manager') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } + it { is_expected.not_to be_enabled } + it { is_expected.not_to be_running } end describe service('pulpcore-worker@1') do diff --git a/spec/acceptance/plugins_spec.rb b/spec/acceptance/plugins_spec.rb index a47e7d72..f224244d 100644 --- a/spec/acceptance/plugins_spec.rb +++ b/spec/acceptance/plugins_spec.rb @@ -37,8 +37,8 @@ end describe service('pulpcore-resource-manager') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } + it { is_expected.not_to be_enabled } + it { is_expected.not_to be_running } end describe port(80) do diff --git a/spec/acceptance/use_pulp2_content_route_spec.rb b/spec/acceptance/use_pulp2_content_route_spec.rb index 2017d263..8c52641a 100644 --- a/spec/acceptance/use_pulp2_content_route_spec.rb +++ b/spec/acceptance/use_pulp2_content_route_spec.rb @@ -40,8 +40,8 @@ class { 'pulpcore::plugin::rpm': end describe service('pulpcore-resource-manager') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } + it { is_expected.not_to be_enabled } + it { is_expected.not_to be_running } end describe port(80) do diff --git a/spec/classes/pulpcore_spec.rb b/spec/classes/pulpcore_spec.rb index fe89e075..5a58e036 100644 --- a/spec/classes/pulpcore_spec.rb +++ b/spec/classes/pulpcore_spec.rb @@ -127,7 +127,7 @@ is_expected.to contain_systemd__unit_file('pulpcore-content.socket') is_expected.to contain_systemd__unit_file('pulpcore-content.service') is_expected.to contain_file('/etc/systemd/system/pulpcore-content.socket').that_comes_before('Service[pulpcore-content.service]') - is_expected.to contain_systemd__unit_file('pulpcore-resource-manager.service') + is_expected.to contain_systemd__unit_file('pulpcore-resource-manager.service').with_ensure('absent') is_expected.to contain_systemd__unit_file('pulpcore-worker@.service') is_expected.to contain_service("pulpcore-worker@1.service").with_ensure(true) is_expected.not_to contain_service("pulpcore-worker@2.service") diff --git a/templates/settings.py.erb b/templates/settings.py.erb index 1a65a8c2..f5cb3d6f 100644 --- a/templates/settings.py.erb +++ b/templates/settings.py.erb @@ -1,3 +1,11 @@ +######################################################################################## +# WARNING: This file is externally managed and you should never make manual edits. # +# # +# Not only are your edits likely to be overwritten, there is also a strong possibility # +# of breaking your system. Refer to documentation for the software that installed # +# Pulpcore to determine the safe and persistent way to modify the configuration. # +######################################################################################## + CONTENT_HOST = "<%= scope['pulpcore::servername'] %>" CONTENT_ORIGIN = "https://<%= scope['pulpcore::servername'] %>" SECRET_KEY = "<%= scope['pulpcore::django_secret_key'] %>"