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
This commit is contained in:
parent
839ccc7f20
commit
11b193cab8
@ -41,8 +41,10 @@ define swift::ringbuilder::create(
|
|||||||
|
|
||||||
include swift::deps
|
include swift::deps
|
||||||
|
|
||||||
validate_legacy(Enum['object', 'container', 'account'], 'validate_re', $name,
|
validate_legacy(
|
||||||
['^object|container|account$'])
|
Pattern[/^(object(-(\d)+)?|container|account)$/], 'validate_re', $name,
|
||||||
|
['^(object(-(\d)+)?|container|account)$']
|
||||||
|
)
|
||||||
|
|
||||||
exec { "create_${name}":
|
exec { "create_${name}":
|
||||||
command => "swift-ring-builder /etc/swift/${name}.builder create ${part_power} ${replicas} ${min_part_hours}",
|
command => "swift-ring-builder /etc/swift/${name}.builder create ${part_power} ${replicas} ${min_part_hours}",
|
||||||
|
@ -14,8 +14,10 @@ define swift::ringbuilder::rebalance(
|
|||||||
|
|
||||||
include swift::deps
|
include swift::deps
|
||||||
|
|
||||||
validate_legacy(Enum['object', 'container', 'account'], 'validate_re', $name,
|
validate_legacy(
|
||||||
['^object|container|account$'])
|
Pattern[/^(object(-(\d)+)?|container|account)$/], 'validate_re', $name,
|
||||||
|
['^(object(-(\d)+)?|container|account)$']
|
||||||
|
)
|
||||||
|
|
||||||
if $seed {
|
if $seed {
|
||||||
validate_legacy(Integer, 'validate_re', $seed, ['^\d+$'])
|
validate_legacy(Integer, 'validate_re', $seed, ['^\d+$'])
|
||||||
|
@ -12,7 +12,7 @@ describe 'swift::ringbuilder::create' do
|
|||||||
|
|
||||||
shared_examples 'swift::ringbuilder::create' do
|
shared_examples 'swift::ringbuilder::create' do
|
||||||
describe 'with allowed titles' do
|
describe 'with allowed titles' do
|
||||||
['object', 'container', 'account'].each do |type|
|
['object', 'container', 'account', 'object-1', 'object-123'].each do |type|
|
||||||
describe "when title is #{type}" do
|
describe "when title is #{type}" do
|
||||||
let :title do
|
let :title do
|
||||||
type
|
type
|
||||||
@ -46,13 +46,17 @@ describe 'swift::ringbuilder::create' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'with an invalid title' do
|
describe 'with an invalid title' do
|
||||||
|
['invalid', 'container-1', 'account-1', 'object-a', 'object-12a'].each do |type|
|
||||||
|
describe "when title is #{type}" do
|
||||||
let :title do
|
let :title do
|
||||||
'invalid'
|
type
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should raise_error(Puppet::Error) }
|
it { should raise_error(Puppet::Error) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
:supported_os => OSDefaults.get_supported_os
|
:supported_os => OSDefaults.get_supported_os
|
||||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
describe 'swift::ringbuilder::rebalance' do
|
describe 'swift::ringbuilder::rebalance' do
|
||||||
shared_examples 'swift::ringbuilder::rebalance' do
|
shared_examples 'swift::ringbuilder::rebalance' do
|
||||||
describe 'with allowed titles' do
|
describe 'with allowed titles' do
|
||||||
['object', 'container', 'account'].each do |type|
|
['object', 'container', 'account', 'object-1', 'object-123'].each do |type|
|
||||||
describe "when title is #{type}" do
|
describe "when title is #{type}" do
|
||||||
let :title do
|
let :title do
|
||||||
type
|
type
|
||||||
@ -49,8 +49,10 @@ describe 'swift::ringbuilder::rebalance' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'with an invalid title' do
|
describe 'with an invalid title' do
|
||||||
|
['invalid', 'container-1', 'account-1', 'object-a', 'object-12a'].each do |type|
|
||||||
|
describe "when title is #{type}" do
|
||||||
let :title do
|
let :title do
|
||||||
'invalid'
|
type
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should raise an error' do
|
it 'should raise an error' do
|
||||||
@ -58,6 +60,8 @@ describe 'swift::ringbuilder::rebalance' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
:supported_os => OSDefaults.get_supported_os
|
:supported_os => OSDefaults.get_supported_os
|
||||||
|
Loading…
Reference in New Issue
Block a user