Add support for promoted-max meta attribute
Master/Slave bundles used to have an attribute "masters" to specify how many replicas can be promoted to Master state. That attribute has been deprecated and renamed "promoted-max". Expose the new attribute in the puppet resource bundle, and use it automatically if an instantiated resource is configured with deprecated attribute "masters" with pacemaker 2. Closes-Bug: #1884108 Change-Id: I3033563ba8a28298d63db42dfa2df1960b685e45
This commit is contained in:
parent
5ab1505d24
commit
bb6709c19a
|
@ -27,6 +27,7 @@ Puppet::Type.type(:pcmk_bundle).provide(:default) do
|
||||||
image = @resource[:image]
|
image = @resource[:image]
|
||||||
replicas = @resource[:replicas]
|
replicas = @resource[:replicas]
|
||||||
masters = @resource[:masters]
|
masters = @resource[:masters]
|
||||||
|
promoted_max = @resource[:promoted_max]
|
||||||
container_options = @resource[:container_options]
|
container_options = @resource[:container_options]
|
||||||
options = @resource[:options]
|
options = @resource[:options]
|
||||||
run_command = @resource[:run_command]
|
run_command = @resource[:run_command]
|
||||||
|
@ -56,6 +57,12 @@ Puppet::Type.type(:pcmk_bundle).provide(:default) do
|
||||||
if masters
|
if masters
|
||||||
cmd += " masters=#{masters}"
|
cmd += " masters=#{masters}"
|
||||||
end
|
end
|
||||||
|
if promoted_max
|
||||||
|
if update
|
||||||
|
cmd += " masters="
|
||||||
|
end
|
||||||
|
cmd += " promoted-max=#{promoted_max}"
|
||||||
|
end
|
||||||
if options
|
if options
|
||||||
cmd += ' options="' + options + '"'
|
cmd += ' options="' + options + '"'
|
||||||
end
|
end
|
||||||
|
@ -230,6 +237,13 @@ Puppet::Type.type(:pcmk_bundle).provide(:default) do
|
||||||
def masters=(value)
|
def masters=(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def promoted_max
|
||||||
|
@resource[:promoted_max]
|
||||||
|
end
|
||||||
|
|
||||||
|
def promoted_max=(value)
|
||||||
|
end
|
||||||
|
|
||||||
def options
|
def options
|
||||||
@resource[:options]
|
@resource[:options]
|
||||||
end
|
end
|
||||||
|
|
|
@ -116,6 +116,21 @@ Puppet::Type.newtype(:pcmk_bundle) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
newproperty(:promoted_max) do
|
||||||
|
desc "number of clones promotable to master"
|
||||||
|
|
||||||
|
munge do |value|
|
||||||
|
if value.is_a?(String)
|
||||||
|
unless value =~ /^[\d]+$/
|
||||||
|
raise ArgumentError, "promoted_max must be an integer"
|
||||||
|
end
|
||||||
|
value = Integer(value)
|
||||||
|
end
|
||||||
|
raise ArgumentError, "promoted_max must be an integer >= 1" if value < 1
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
newproperty(:options) do
|
newproperty(:options) do
|
||||||
desc "docker options"
|
desc "docker options"
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
# (optional) Number of masters to be set in the bundle
|
# (optional) Number of masters to be set in the bundle
|
||||||
# Defaults to undef
|
# Defaults to undef
|
||||||
#
|
#
|
||||||
|
# [*promoted_max*]
|
||||||
|
# (optional) Number of masters to be set in the bundle. Supersedes
|
||||||
|
# deprecated option 'masters' in pacemaker 2
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
# [*options*]
|
# [*options*]
|
||||||
# (optional) Options to be passed to the docker run command
|
# (optional) Options to be passed to the docker run command
|
||||||
# Defaults to undef
|
# Defaults to undef
|
||||||
|
@ -126,6 +131,7 @@ define pacemaker::resource::bundle(
|
||||||
$container_options = undef,
|
$container_options = undef,
|
||||||
$replicas = undef,
|
$replicas = undef,
|
||||||
$masters = undef,
|
$masters = undef,
|
||||||
|
$promoted_max = undef,
|
||||||
$options = undef,
|
$options = undef,
|
||||||
$run_command = undef,
|
$run_command = undef,
|
||||||
$storage_maps = undef,
|
$storage_maps = undef,
|
||||||
|
@ -150,12 +156,33 @@ define pacemaker::resource::bundle(
|
||||||
# target-dir=/var/log options=ro storage-map id=bar-storage-test
|
# target-dir=/var/log options=ro storage-map id=bar-storage-test
|
||||||
# source-dir=/foo target-dir=/bar options=wr
|
# source-dir=/foo target-dir=/bar options=wr
|
||||||
|
|
||||||
|
if $promoted_max {
|
||||||
|
if !$::pacemaker::pcs_010 {
|
||||||
|
fail('Cannot use \'promoted_max\' without pacemaker 2 and pcs >= 0.10')
|
||||||
|
} else {
|
||||||
|
$used_promoted_max = $promoted_max
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# promoted_max supersedes masters in pacemaker 2 (pcs >= 0.10)
|
||||||
|
if $masters and $::pacemaker::pcs_010 {
|
||||||
|
if $promoted_max {
|
||||||
|
warning('Both \'masters\' and \'promoted_max\' specified, using option \'promoted_max\'')
|
||||||
|
} else {
|
||||||
|
$used_promoted_max = $masters
|
||||||
|
}
|
||||||
|
$used_masters = undef
|
||||||
|
} else {
|
||||||
|
$used_masters = $masters
|
||||||
|
}
|
||||||
|
|
||||||
pcmk_bundle { $name:
|
pcmk_bundle { $name:
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
image => $image,
|
image => $image,
|
||||||
container_options => $container_options,
|
container_options => $container_options,
|
||||||
replicas => $replicas,
|
replicas => $replicas,
|
||||||
masters => $masters,
|
masters => $used_masters,
|
||||||
|
promoted_max => $used_promoted_max,
|
||||||
options => $options,
|
options => $options,
|
||||||
run_command => $run_command,
|
run_command => $run_command,
|
||||||
storage_maps => $storage_maps,
|
storage_maps => $storage_maps,
|
||||||
|
|
Loading…
Reference in New Issue