Skip to content

Commit

Permalink
A stopped volume should not block execution
Browse files Browse the repository at this point in the history
This only invokes `gluster volume status` if the volume is started. This
prevents a stopped volume from causing Puppet (or Facter) failures.

Closes #1.
  • Loading branch information
Scott Merrill committed Sep 5, 2014
1 parent 21dbc08 commit 6df3dde
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/facter/gluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
end
end
output = Facter::Util::Resolution.exec("#{binary} peer status")
if output =~ /^Number of Peers: (\d+)$/
peer_count = $1.to_i
end
peer_count = $1.to_i if output =~ /^Number of Peers: (\d+)$/
if peer_count > 0 then
peer_list = output.scan(/^Hostname: (.+)$/).flatten.join(',')
# note the stderr redirection here
Expand All @@ -35,14 +33,17 @@
if output != "No volumes present in cluster" then
output.split.each do |vol|
output = Facter::Util::Resolution.exec("#{binary} volume info #{vol}")
status = $1 if output.scan =~ /^Status: (.+)$/
bricks = output.scan(/^Brick[^:]+: (.+)$/).flatten
volume_bricks[vol] = bricks
options = output.scan(/^(\w+\.[^:]+: .+)$/).flatten
if options then
volume_options[vol] = options
end
output = Facter::Util::Resolution.exec("#{binary} volume status #{vol}")
volume_ports[vol] = output.scan(/^Brick [^\t]+\t+(\d+)/).flatten.uniq.sort
if status == "Started" then
output = Facter::Util::Resolution.exec("#{binary} volume status #{vol}")
volume_ports[vol] = output.scan(/^Brick [^\t]+\t+(\d+)/).flatten.uniq.sort
end
end
end
end
Expand Down

0 comments on commit 6df3dde

Please sign in to comment.