Allow defining a section without settings

(account|container|object)-server.conf requires sections for each
services but these sections sometimes don't require settings when
service defaults are used.

This change allows defining only sections using *_config resources.

Depends-on: https://review.opendev.org/849235
Change-Id: I827c06cc994e13b900a9eeaeaec7849a243732e2
This commit is contained in:
Takashi Kajinami 2022-01-24 10:07:27 +09:00
parent 1e32789cfd
commit 9bd09b15bb
9 changed files with 75 additions and 45 deletions

View File

@ -3,6 +3,12 @@ Puppet::Type.type(:swift_account_config).provide(
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def setting
val = super
return nil if val == ''
val
end
def self.file_path
'/etc/swift/account-server.conf'
end

View File

@ -3,6 +3,12 @@ Puppet::Type.type(:swift_container_config).provide(
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def setting
val = super
return nil if val == ''
val
end
def self.file_path
'/etc/swift/container-server.conf'
end

View File

@ -3,6 +3,12 @@ Puppet::Type.type(:swift_object_config).provide(
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def setting
val = super
return nil if val == ''
val
end
def self.file_path
'/etc/swift/object-server.conf'
end

View File

@ -4,7 +4,7 @@ Puppet::Type.newtype(:swift_account_config) do
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from /etc/swift/account-server.conf'
newvalues(/\S+\/\S+/)
newvalues(/\S+\/\S*/)
end
newproperty(:value) do

View File

@ -4,7 +4,7 @@ Puppet::Type.newtype(:swift_container_config) do
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from /etc/swift/container-server.conf'
newvalues(/\S+\/\S+/)
newvalues(/\S+\/\S*/)
end
newproperty(:value) do

View File

@ -4,7 +4,7 @@ Puppet::Type.newtype(:swift_object_config) do
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from /etc/swift/object-server.conf'
newvalues(/\S+\/\S+/)
newvalues(/\S+\/\S*/)
end
newproperty(:value) do

View File

@ -435,51 +435,37 @@ define swift::storage::server(
$type_opts = {
# account-server
# account-auditor
'account-auditor/' => {'ensure' => present},
# account-replicator
'account-replicator/' => {'ensure' => present},
'account-replicator/concurrency' => {'value' => $replicator_concurrency},
'account-replicator/interval' => {'value' => $replicator_interval},
# account-reaper
'account-reaper/' => {'ensure' => present},
'account-reaper/concurrency' => {'value' => $reaper_concurrency},
}
file_line { 'account-reaper':
path => $config_file_full_path,
line => '[account-reaper]',
tag => 'swift-config-file',
}
}
'container': {
$type_opts = {
'DEFAULT/allowed_sync_hosts' => {'value' => join($::swift::storage::container::allowed_sync_hosts, ',')},
# container-server
# container-auditor
'container-auditor/' => {'ensure' => present},
# container-replicator
'container-replicator/' => {'ensure' => present},
'container-replicator/concurrency' => {'value' => $replicator_concurrency},
'container-replicator/interval' => {'value' => $replicator_interval},
# container-updater
'container-updater/' => {'ensure' => present},
'container-updater/concurrency' => {'value' => $updater_concurrency},
# container-sync
'container-sync/' => {'ensure' => present},
# container-sharder
'container-sharder/' => {'ensure' => present},
'container-sharder/auto_shard' => {'value' => $container_sharder_auto_shard},
'container-sharder/concurrency' => {'value' => $container_sharder_concurrency},
'container-sharder/interval' => {'value' => $container_sharder_interval},
}
file_line { 'container-updater':
path => $config_file_full_path,
line => '[container-updater]',
tag => 'swift-config-file',
}
file_line { 'container-sync':
path => $config_file_full_path,
line => '[container-sync]',
tag => 'swift-config-file',
}
file_line { 'container-sharder':
path => $config_file_full_path,
line => '[container-sharder]',
tag => 'swift-config-file',
}
}
'object': {
$type_opts = {
@ -491,25 +477,18 @@ define swift::storage::server(
'app:object-server/splice' => {'value' => $splice},
'app:object-server/mb_per_sync' => {'value' => $object_server_mb_per_sync},
# object-auditor
'object-auditor/' => {'ensure' => present},
'object-auditor/disk_chunk_size' => {'value' => $auditor_disk_chunk_size},
# object-replicator
'object-replicator/' => {'ensure' => present},
'object-replicator/concurrency' => {'value' => $replicator_concurrency},
'object-replicator/rsync_timeout' => {'value' => $rsync_timeout},
'object-replicator/rsync_bwlimit' => {'value' => $rsync_bwlimit},
# object-updater
'object-updater/' => {'ensure' => present},
'object-updater/concurrency' => {'value' => $updater_concurrency},
# object-reconstructor
}
file_line { 'object-updater':
path => $config_file_full_path,
line => '[object-updater]',
tag => 'swift-config-file',
}
file_line { 'object-reconstructor':
path => $config_file_full_path,
line => '[object-reconstructor]',
tag => 'swift-config-file',
'object-reconstructor/' => {'ensure' => present},
}
}
default: {

View File

@ -70,6 +70,10 @@ describe 'basic swift_config resource' do
ensure_absent_val => 'toto',
}
swift_account_config { 'thisshouldexist3/' :
ensure => present,
}
swift_bench_config { 'DEFAULT/thisshouldexist' :
value => 'foo',
}
@ -106,6 +110,10 @@ describe 'basic swift_config resource' do
ensure_absent_val => 'toto',
}
swift_container_config { 'thisshouldexist3/' :
ensure => present,
}
swift_dispersion_config { 'DEFAULT/thisshouldexist' :
value => 'foo',
}
@ -142,6 +150,10 @@ describe 'basic swift_config resource' do
ensure_absent_val => 'toto',
}
swift_object_config { 'thisshouldexist3/' :
ensure => present,
}
swift_proxy_config { 'DEFAULT/thisshouldexist' :
value => 'foo',
}
@ -185,16 +197,16 @@ describe 'basic swift_config resource' do
apply_manifest(pp, :catch_changes => true)
end
$swift_files = [ '/etc/swift/swift.conf',
'/etc/swift/account-server.conf',
'/etc/swift/swift-bench.conf',
'/etc/swift/container-server.conf',
'/etc/swift/dispersion.conf',
'/etc/swift/object-server.conf',
'/etc/swift/proxy-server.conf',
'/etc/swift/container-sync-realms.conf']
swift_files = [ '/etc/swift/swift.conf',
'/etc/swift/account-server.conf',
'/etc/swift/swift-bench.conf',
'/etc/swift/container-server.conf',
'/etc/swift/dispersion.conf',
'/etc/swift/object-server.conf',
'/etc/swift/proxy-server.conf',
'/etc/swift/container-sync-realms.conf']
$swift_files.each do |swift_conf_file|
swift_files.each do |swift_conf_file|
describe file(swift_conf_file) do
it { is_expected.to exist }
it { is_expected.to contain('thisshouldexist=foo') }
@ -207,5 +219,15 @@ describe 'basic swift_config resource' do
end
end
server_files = [ '/etc/swift/account-server.conf',
'/etc/swift/container-server.conf',
'/etc/swift/object-server.conf']
server_files.each do |swift_conf_file|
describe file(swift_conf_file) do
it { is_expected.to contain('thisshouldexist3') }
end
end
end
end

View File

@ -97,9 +97,12 @@ describe 'swift::storage::server' do
is_expected.to contain_swift_account_config('DEFAULT/log_statsd_sample_rate_factor').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config('DEFAULT/log_statsd_metric_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config('account-auditor/').with_ensure('present')
is_expected.to contain_swift_account_config('account-replicator/').with_ensure('present')
is_expected.to contain_swift_account_config('account-replicator/rsync_module').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config('account-replicator/concurrency').with_value(1)
is_expected.to contain_swift_account_config('account-replicator/interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config('account-reaper/').with_ensure('present')
is_expected.to contain_swift_account_config('account-reaper/concurrency').with_value(1)
}
@ -218,10 +221,14 @@ describe 'swift::storage::server' do
is_expected.to contain_swift_container_config('DEFAULT/log_statsd_metric_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_container_config('DEFAULT/allowed_sync_hosts').with_value('127.0.0.1')
is_expected.to contain_swift_container_config('container-auditor/').with_ensure('present')
is_expected.to contain_swift_container_config('container-replicator/').with_ensure('present')
is_expected.to contain_swift_container_config('container-replicator/rsync_module').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_container_config('container-replicator/concurrency').with_value(1)
is_expected.to contain_swift_container_config('container-replicator/interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_container_config('container-updater/').with_ensure('present')
is_expected.to contain_swift_container_config('container-updater/concurrency').with_value(1)
is_expected.to contain_swift_container_config('container-sharder/').with_ensure('present')
is_expected.to contain_swift_container_config('container-sharder/auto_shard').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_container_config('container-sharder/concurrency').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_container_config('container-sharder/interval').with_value('<SERVICE DEFAULT>')
@ -347,13 +354,17 @@ describe 'swift::storage::server' do
is_expected.to contain_swift_object_config('DEFAULT/client_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('app:object-server/splice').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('app:object-server/mb_per_sync').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('object-auditor/').with_ensure('present')
is_expected.to contain_swift_object_config('object-auditor/disk_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('object-replicator/').with_ensure('present')
is_expected.to contain_swift_object_config('object-replicator/rsync_module').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('object-replicator/rsync_module').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('object-replicator/concurrency').with_value(1)
is_expected.to contain_swift_object_config('object-replicator/rsync_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('object-replicator/rsync_bwlimit').with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_object_config('object-updater/').with_ensure('present')
is_expected.to contain_swift_object_config('object-updater/concurrency').with_value(1)
is_expected.to contain_swift_object_config('object-reconstructor/').with_ensure('present')
}
context 'with customized pipeline' do