Files
puppet-swift/manifests/ringbuilder/rebalance.pp
Takashi Kajinami 11b193cab8 Fix type validation warning for storage policy rings
Since 63688a14e5 was merged, this module
support configuring storage policies.

When multiple storage policies are used, we need to create multiple
object rings like object.ring.gz, object-1.ring.gz. However the current
regexp to validate the ring name does not consider this format and
shows the type validation warning when creating a non-default policy
rings.

This change updates the regexp used in validation to accept that
object-<number> format as well.

Closes-Bug: #1987260
Change-Id: Ibc7479e7defbfa4c49bf3c9f1574cdcf61b90ab9
2022-08-22 19:37:40 +09:00

34 lines
934 B
Puppet

# Swift::Ring::Rebalance
# Reblances the specified ring. Assumes that the ring already exists
# and is stored at /etc/swift/${name}.builder
#
# == Parameters
#
# [*name*] Type of ring to rebalance. The ring file is assumed to be at the path
# /etc/swift/${name}.builder
#
# [*seed*] Optional. Seed value used to seed pythons pseudo-random for ringbuilding.
define swift::ringbuilder::rebalance(
$seed = undef
) {
include swift::deps
validate_legacy(
Pattern[/^(object(-(\d)+)?|container|account)$/], 'validate_re', $name,
['^(object(-(\d)+)?|container|account)$']
)
if $seed {
validate_legacy(Integer, 'validate_re', $seed, ['^\d+$'])
}
exec { "rebalance_${name}":
command => strip("swift-ring-builder /etc/swift/${name}.builder rebalance ${seed}"),
path => ['/usr/bin'],
refreshonly => true,
before => Anchor['swift::config::end'],
returns => [0, 1],
}
}