Add tries/try_sleep to the constraint classes
Let's add tries/try_sleep retry logic to the constraint classes as well just like it exists for resources and properties. Change-Id: Iba1017c33b1cd4d56a3ee8824d851b38cfdbc2d3
This commit is contained in:
@@ -28,7 +28,7 @@ Puppet::Type.type(:pcmk_constraint).provide(:default) do
|
||||
end
|
||||
|
||||
# do pcs create
|
||||
pcs('create constraint', resource_name, cmd)
|
||||
pcs('create constraint', resource_name, cmd, @resource[:tries], @resource[:try_sleep])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -46,7 +46,7 @@ Puppet::Type.type(:pcmk_constraint).provide(:default) do
|
||||
cmd = 'constraint order remove ' + first_resource + ' ' + second_resource
|
||||
end
|
||||
|
||||
pcs('constraint delete', resource_name, cmd)
|
||||
pcs('constraint delete', resource_name, cmd, @resource[:tries], @resource[:try_sleep])
|
||||
end
|
||||
|
||||
def exists?
|
||||
|
||||
@@ -42,4 +42,39 @@ Puppet::Type.newtype(:pcmk_constraint) do
|
||||
newparam(:master_slave, :boolean => true, :parent => Puppet::Parameter::Boolean) do
|
||||
desc "Enable master/slave support with multistage"
|
||||
end
|
||||
## borrowed from exec.rb
|
||||
newparam(:tries) do
|
||||
desc "The number of times to attempt to create a pcs resource.
|
||||
Defaults to '1'."
|
||||
|
||||
munge do |value|
|
||||
if value.is_a?(String)
|
||||
unless value =~ /^[\d]+$/
|
||||
raise ArgumentError, "Tries must be an integer"
|
||||
end
|
||||
value = Integer(value)
|
||||
end
|
||||
raise ArgumentError, "Tries must be an integer >= 1" if value < 1
|
||||
value
|
||||
end
|
||||
|
||||
defaultto 1
|
||||
end
|
||||
|
||||
newparam(:try_sleep) do
|
||||
desc "The time to sleep in seconds between 'tries'."
|
||||
|
||||
munge do |value|
|
||||
if value.is_a?(String)
|
||||
unless value =~ /^[-\d.]+$/
|
||||
raise ArgumentError, "try_sleep must be a number"
|
||||
end
|
||||
value = Float(value)
|
||||
end
|
||||
raise ArgumentError, "try_sleep cannot be a negative number" if value < 0
|
||||
value
|
||||
end
|
||||
|
||||
defaultto 0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,14 @@
|
||||
# (optional) Whether to set a resource with one node as master
|
||||
# Defaults to false
|
||||
#
|
||||
# [*tries*]
|
||||
# (optional) How many times to attempt to create the constraint
|
||||
# Defaults to 1
|
||||
#
|
||||
# [*try_sleep*]
|
||||
# (optional) How long to wait between tries, in seconds
|
||||
# Defaults to 0
|
||||
#
|
||||
# [*ensure*]
|
||||
# (optional) Whether to make sure the constraint is present or absent
|
||||
# Defaults to present
|
||||
@@ -52,6 +60,8 @@ define pacemaker::constraint::colocation (
|
||||
$score,
|
||||
$master_slave = false,
|
||||
$ensure = present,
|
||||
$tries = 1,
|
||||
$try_sleep = 0,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
@@ -65,6 +75,8 @@ define pacemaker::constraint::colocation (
|
||||
score => $score,
|
||||
master_slave => $master_slave,
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,14 @@
|
||||
# [*score*]
|
||||
# (required) Numeric score to weight the importance of the constraint
|
||||
#
|
||||
# [*tries*]
|
||||
# (optional) How many times to attempt to create the constraint
|
||||
# Defaults to 1
|
||||
#
|
||||
# [*try_sleep*]
|
||||
# (optional) How long to wait between tries, in seconds
|
||||
# Defaults to 0
|
||||
#
|
||||
# [*ensure*]
|
||||
# (optional) Whether to make sure the constraint is present or absent
|
||||
# Defaults to present
|
||||
@@ -46,7 +54,9 @@ define pacemaker::constraint::location (
|
||||
$resource,
|
||||
$location,
|
||||
$score,
|
||||
$ensure='present'
|
||||
$ensure = 'present',
|
||||
$tries = 1,
|
||||
$try_sleep = 0,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
@@ -58,6 +68,8 @@ define pacemaker::constraint::location (
|
||||
location => $location,
|
||||
score => $score,
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,14 @@
|
||||
# (optional) Only used for order constraints, action to take on second resource
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*tries*]
|
||||
# (optional) How many times to attempt to create the constraint
|
||||
# Defaults to 1
|
||||
#
|
||||
# [*try_sleep*]
|
||||
# (optional) How long to wait between tries, in seconds
|
||||
# Defaults to 0
|
||||
#
|
||||
# [*ensure*]
|
||||
# (optional) Whether to make sure the constraint is present or absent
|
||||
# Defaults to present
|
||||
@@ -60,6 +68,8 @@ define pacemaker::constraint::order (
|
||||
$second_action,
|
||||
$ensure = present,
|
||||
$constraint_params = undef,
|
||||
$tries = 1,
|
||||
$try_sleep = 0,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
@@ -76,5 +86,7 @@ define pacemaker::constraint::order (
|
||||
second_action => $second_action,
|
||||
constraint_params => $constraint_params,
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user