Fix type validation warning for storage policy rings
Since63688a14e5
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 (cherry picked from commit11b193cab8
)
This commit is contained in:
parent
ab3cf92d79
commit
2d1b0a7f8a
|
@ -41,8 +41,10 @@ define swift::ringbuilder::create(
|
|||
|
||||
include swift::deps
|
||||
|
||||
validate_legacy(Enum['object', 'container', 'account'], 'validate_re', $name,
|
||||
['^object|container|account$'])
|
||||
validate_legacy(
|
||||
Pattern[/^(object(-(\d)+)?|container|account)$/], 'validate_re', $name,
|
||||
['^(object(-(\d)+)?|container|account)$']
|
||||
)
|
||||
|
||||
exec { "create_${name}":
|
||||
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
|
||||
|
||||
validate_legacy(Enum['object', 'container', 'account'], 'validate_re', $name,
|
||||
['^object|container|account$'])
|
||||
validate_legacy(
|
||||
Pattern[/^(object(-(\d)+)?|container|account)$/], 'validate_re', $name,
|
||||
['^(object(-(\d)+)?|container|account)$']
|
||||
)
|
||||
|
||||
if $seed {
|
||||
validate_legacy(Integer, 'validate_re', $seed, ['^\d+$'])
|
||||
|
|
|
@ -12,7 +12,7 @@ describe 'swift::ringbuilder::create' do
|
|||
|
||||
shared_examples 'swift::ringbuilder::create' 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
|
||||
let :title do
|
||||
type
|
||||
|
@ -46,11 +46,15 @@ describe 'swift::ringbuilder::create' do
|
|||
end
|
||||
|
||||
describe 'with an invalid title' do
|
||||
let :title do
|
||||
'invalid'
|
||||
end
|
||||
['invalid', 'container-1', 'account-1', 'object-a', 'object-12a'].each do |type|
|
||||
describe "when title is #{type}" do
|
||||
let :title do
|
||||
type
|
||||
end
|
||||
|
||||
it { should raise_error(Puppet::Error) }
|
||||
it { should raise_error(Puppet::Error) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe 'swift::ringbuilder::rebalance' do
|
||||
shared_examples 'swift::ringbuilder::rebalance' 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
|
||||
let :title do
|
||||
type
|
||||
|
@ -49,12 +49,16 @@ describe 'swift::ringbuilder::rebalance' do
|
|||
end
|
||||
|
||||
describe 'with an invalid title' do
|
||||
let :title do
|
||||
'invalid'
|
||||
end
|
||||
['invalid', 'container-1', 'account-1', 'object-a', 'object-12a'].each do |type|
|
||||
describe "when title is #{type}" do
|
||||
let :title do
|
||||
type
|
||||
end
|
||||
|
||||
it 'should raise an error' do
|
||||
expect { catalogue }.to raise_error(Puppet::Error)
|
||||
it 'should raise an error' do
|
||||
expect { catalogue }.to raise_error(Puppet::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue