summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2014-03-12 11:34:52 -0400
committerJames Shubin <james@shubin.ca>2014-03-16 22:39:08 -0400
commit05576cd410bb2616ce72e3e9e24850f911cbb6dc (patch)
tree0286fce76ac26f8aa74caf96c04cc70f180f6101
parentfbe9e9cb4bd8cc4278eba8e16bc69f009f334d7a (diff)
downloadpuppet-gluster-05576cd410bb2616ce72e3e9e24850f911cbb6dc.tar.gz
puppet-gluster-05576cd410bb2616ce72e3e9e24850f911cbb6dc.tar.xz
puppet-gluster-05576cd410bb2616ce72e3e9e24850f911cbb6dc.zip
Setting volume properties should be race-free.
This isn't essential, as ensuring this is race-free is really up to glusterfs, but with this patch you reduce the likelihood to ~0% that you'll see a: "volume set: failed: Another transaction is in progress." error. The error isn't harmful, but now we'll see less unnecessary red.
-rw-r--r--manifests/simple.pp3
-rw-r--r--manifests/volume/property.pp36
-rw-r--r--manifests/volume/property/group.pp5
3 files changed, 30 insertions, 14 deletions
diff --git a/manifests/simple.pp b/manifests/simple.pp
index 0fa75da..6bc6c11 100644
--- a/manifests/simple.pp
+++ b/manifests/simple.pp
@@ -176,7 +176,8 @@ class gluster::simple(
if "${setgroup}" != '' {
$setgroup_yaml = inline_template("<%= @valid_volumes.inject(Hash.new) { |h,i| {i+'#'+@setgroup => {}}.merge(h) }.to_yaml %>")
$setgroup_hash = parseyaml($setgroup_yaml)
- create_resources('gluster::volume::property::group', $setgroup_hash)
+ $setgroup_defaults = {'vip' => "${vip}"}
+ create_resources('gluster::volume::property::group', $setgroup_hash, $setgroup_defaults)
}
}
diff --git a/manifests/volume/property.pp b/manifests/volume/property.pp
index a7f6218..39dff6b 100644
--- a/manifests/volume/property.pp
+++ b/manifests/volume/property.pp
@@ -19,6 +19,7 @@
define gluster::volume::property(
$value,
+ $vip = '', # vip of the cluster (optional but recommended)
$autotype = true # set to false to disable autotyping
) {
include gluster::xml
@@ -152,18 +153,29 @@ define gluster::volume::property(
}
}
- # volume set <VOLNAME> <KEY> <VALUE>
- # set a volume property only if value doesn't match what is available
- # FIXME: check that the value we're setting isn't the default
- # FIXME: you can check defaults with... gluster volume set help | ...
- exec { "/usr/sbin/gluster volume set ${volume} ${key} ${safe_value}":
- unless => "/usr/bin/test \"`/usr/sbin/gluster volume --xml info ${volume} | ${vardir}/xml.py property --key '${key}'`\" = '${safe_value}'",
- onlyif => "/usr/sbin/gluster volume list | /bin/grep -qxF '${volume}' -",
- logoutput => on_failure,
- require => [
- Gluster::Volume[$volume],
- File["${vardir}/xml.py"],
- ],
+ $valid_vip = "${vip}" ? {
+ '' => $::gluster::server::vip,
+ default => "${vip}",
+ }
+
+ # returns interface name that has vip, or '' if none are found.
+ $vipif = inline_template("<%= @interfaces.split(',').find_all {|x| '${valid_vip}' == scope.lookupvar('ipaddress_'+x) }[0,1].join('') %>")
+
+ # run if vip not defined (bypass mode) or if vip exists on this machine
+ if ("${valid_vip}" == '' or "${vipif}" != '') {
+ # volume set <VOLNAME> <KEY> <VALUE>
+ # set a volume property only if value doesn't match what is available
+ # FIXME: check that the value we're setting isn't the default
+ # FIXME: you can check defaults with... gluster volume set help | ...
+ exec { "/usr/sbin/gluster volume set ${volume} ${key} ${safe_value}":
+ unless => "/usr/bin/test \"`/usr/sbin/gluster volume --xml info ${volume} | ${vardir}/xml.py property --key '${key}'`\" = '${safe_value}'",
+ onlyif => "/usr/sbin/gluster volume list | /bin/grep -qxF '${volume}' -",
+ logoutput => on_failure,
+ require => [
+ Gluster::Volume[$volume],
+ File["${vardir}/xml.py"],
+ ],
+ }
}
}
diff --git a/manifests/volume/property/group.pp b/manifests/volume/property/group.pp
index 02b5fcb..d0b7a60 100644
--- a/manifests/volume/property/group.pp
+++ b/manifests/volume/property/group.pp
@@ -23,6 +23,7 @@
# NOTE: this does the equivalent of: gluster volume set <VOLNAME> group <GROUP>
define gluster::volume::property::group(
+ $vip = '', # vip of the cluster (optional but recommended)
) {
include gluster::xml
include gluster::vardir
@@ -62,8 +63,10 @@ define gluster::volume::property::group(
$group_data_yaml = inline_template("<%= @group_data_list.inject(Hash.new) { |h,i| { '${volume}#'+((i.split('=').length == 2) ? i.split('=')[0] : '') => {'value' => ((i.split('=').length == 2) ? i.split('=')[1] : '')} }.merge(h) }.to_yaml %>")
# build into a hash
$group_data_hash = parseyaml($group_data_yaml)
+ # pass through the vip
+ $group_data_defaults = {'vip' => "${vip}"}
# create the properties
- create_resources('gluster::volume::property', $group_data_hash)
+ create_resources('gluster::volume::property', $group_data_hash, $group_data_defaults)
}
}