Multiple rsync modules

Currently with puppet-swift, each server has a global [ object ] rsync
module name. As a consequence, the number of rsync connection is set
globally for each server.

With this patch, it's possible to define one rsync module per device,
which makes is to much better: it handles both the cases where a hard
drive fails, or when all drives need to sync data.

Note that with this patch, the default is to keep the old behavior of
one single rsync module per service type (a / c / o).

Change-Id: Id2ad5b10b9286c3740d6ebdbc61d2fd9792ba496
This commit is contained in:
Thomas Goirand
2022-08-22 10:23:26 +02:00
committed by Takashi Kajinami
parent 839ccc7f20
commit 5a82bf2e6a
3 changed files with 148 additions and 9 deletions

View File

@@ -0,0 +1,8 @@
---
features:
- |
It is now possible to use one rsync module per device. This is useful as
it allows to set the number of rsync connection per device, instead of it
being a gloval value per server. For it, two new parameters exist in the
class `storage::server`: `rsync_module_per_device` that enables this
new feature, and `device_names` that defines the list of devices.

View File

@@ -18,6 +18,15 @@
# (optional) The directory where the physical storage device will be mounted.
# Defaults to '/srv/node'.
#
# [*rsync_module_per_device*]
# (optional) Define one rsync module per device. If this is set to true, then
# the device_names must be set with an array of device names.
# Defaults to false.
#
# [*device_names*]
# (optional) List of devices to set as an rsync module list in rsyncd.conf.
# Defaults to an empty array.
#
# [*owner*]
# (optional) Owner (uid) of rsync server.
# Defaults to $::swift::params::user.
@@ -195,6 +204,8 @@ define swift::storage::server(
$type,
$storage_local_net_ip,
$devices = '/srv/node',
$rsync_module_per_device = false,
$device_names = [],
$owner = undef,
$group = undef,
$incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
@@ -260,6 +271,7 @@ define swift::storage::server(
validate_legacy(Enum['object', 'container', 'account'], 'validate_re',
$type, ['^object|container|account$'])
validate_legacy(Array, 'validate_array', $pipeline)
validate_legacy(Array, 'validate_array', $device_names)
if ! is_service_default($splice) {
validate_legacy(Boolean, 'validate_bool', $splice)
@@ -269,15 +281,36 @@ define swift::storage::server(
# rsync::server should be included before rsync::server::module
include swift::storage
rsync::server::module { $type:
path => $devices,
lock_file => "/var/lock/${type}.lock",
uid => pick($owner, $::swift::params::user),
gid => pick($group, $::swift::params::group),
incoming_chmod => $incoming_chmod,
outgoing_chmod => $outgoing_chmod,
max_connections => $max_connections,
read_only => false,
if $rsync_module_per_device {
if empty($device_names) {
fail('device_names is required when rsync_module_per_device is true')
}
$device_names.each |String $device_name| {
rsync::server::module { "${type}_${device_name}":
path => $devices,
lock_file => "/var/lock/${type}_${device_name}.lock",
uid => pick($owner, $::swift::params::user),
gid => pick($group, $::swift::params::group),
incoming_chmod => $incoming_chmod,
outgoing_chmod => $outgoing_chmod,
max_connections => $max_connections,
read_only => false,
}
}
$rsync_module = "{replication_ip}::${type}_{device}"
} else {
rsync::server::module { $type:
path => $devices,
lock_file => "/var/lock/${type}.lock",
uid => pick($owner, $::swift::params::user),
gid => pick($group, $::swift::params::group),
incoming_chmod => $incoming_chmod,
outgoing_chmod => $outgoing_chmod,
max_connections => $max_connections,
read_only => false,
}
$rsync_module = $::os_service_default
}
$config_file_full_path = "/etc/swift/${config_file_path}"
@@ -323,6 +356,7 @@ define swift::storage::server(
"app:${type}-server/set log_address" => {'value' => $log_address},
# auditor
# replicator
"${type}-replicator/rsync_module" => {'value' => $rsync_module},
}
file_line { "${type}-auditor":

View File

@@ -94,6 +94,7 @@ 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-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/concurrency').with_value(1)
@@ -118,6 +119,37 @@ describe 'swift::storage::server' do
is_expected.to contain_swift_account_config('pipeline:main/pipeline').with_value('healthcheck recon account-server')
}
end
context 'with rsync_module_per_device' do
before do
params.merge!({
:rsync_module_per_device => true,
:device_names => ['sda', 'sdb'],
})
it { is_expected.to contain_rsync__server__module('account_sda').with(
:path => '/srv/node',
:lock_file => '/var/lock/account_sda.lock',
:uid => 'swift',
:gid => 'swift',
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:max_connections => 25,
:read_only => false,
)}
it { is_expected.to contain_rsync__server__module('account_sdb').with(
:path => '/srv/node',
:lock_file => '/var/lock/account_sdb.lock',
:uid => 'swift',
:gid => 'swift',
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:max_connections => 25,
:read_only => false,
)}
it { is_expected.to contain_swift_account_config('account-replicator/rsync_module').with_value('{replication_ip}::account_{device}') }
end
end
end
describe 'for type container' do
@@ -180,6 +212,7 @@ 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-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/concurrency').with_value(1)
@@ -207,6 +240,37 @@ describe 'swift::storage::server' do
is_expected.to contain_swift_container_config('pipeline:main/pipeline').with_value('healthcheck recon container-server')
}
end
context 'with rsync_module_per_device' do
before do
params.merge!({
:rsync_module_per_device => true,
:device_names => ['sda', 'sdb'],
})
it { is_expected.to contain_rsync__server__module('container_sda').with(
:path => '/srv/node',
:lock_file => '/var/lock/container_sda.lock',
:uid => 'swift',
:gid => 'swift',
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:max_connections => 25,
:read_only => false,
)}
it { is_expected.to contain_rsync__server__module('container_sdb').with(
:path => '/srv/node',
:lock_file => '/var/lock/container_sdb.lock',
:uid => 'swift',
:gid => 'swift',
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:max_connections => 25,
:read_only => false,
)}
it { is_expected.to contain_swift_container_config('container-replicator/rsync_module').with_value('{replication_ip}::container_{device}') }
end
end
end
describe 'for type object' do
@@ -275,6 +339,8 @@ describe 'swift::storage::server' do
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/disk_chunk_size').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/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>')
@@ -300,6 +366,37 @@ describe 'swift::storage::server' do
is_expected.to contain_swift_object_config('pipeline:main/pipeline').with_value('healthcheck recon object-server')
}
end
context 'with rsync_module_per_device' do
before do
params.merge!({
:rsync_module_per_device => true,
:device_names => ['sda', 'sdb'],
})
it { is_expected.to contain_rsync__server__module('object_sda').with(
:path => '/srv/node',
:lock_file => '/var/lock/object_sda.lock',
:uid => 'swift',
:gid => 'swift',
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:max_connections => 25,
:read_only => false,
)}
it { is_expected.to contain_rsync__server__module('object_sdb').with(
:path => '/srv/node',
:lock_file => '/var/lock/object_sdb.lock',
:uid => 'swift',
:gid => 'swift',
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
:max_connections => 25,
:read_only => false,
)}
it { is_expected.to contain_swift_object_config('object-replicator/rsync_module').with_value('{replication_ip}::object_{device}') }
end
end
end
end