Gitweb: http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=commit... Commit: d9e40ee832d3705c3e952f11efa79d6e155d6277 Parent: 522fef7acb26c7cdc46f5b0da8b20c1900c692b7 Author: Ryan O'Hara rohara@redhat.com AuthorDate: Mon Jan 24 13:54:25 2011 -0600 Committer: Ryan O'Hara rohara@redhat.com CommitterDate: Mon Feb 7 12:42:39 2011 -0600
fence_scsi: verify that on/off actions succeed
This patch adds code to verify that both "on" and "off" actions are successful. This is needed because there seem to be some arrays that do not report an error even when no registration was created, etc.
These verification steps takes places after the action has been performed successfully. If an error was encountered while performing either an "on" or "off" action, fence_scsi will exit and no verification will take place. Failure to verify that an action was successful for any device will result is failure.
For the "on" action, do_verify_on will check that the key was successfully registered with each devices and that a reservation exists on each device.
For the "off" action, do_verify_off will check that the key was removed from each device and that a reservation exists on each device.
Resolves: rhbz#644385
Signed-off-by: Ryan O'Hara rohara@redhat.com Reviewed-by: Lon Hohberger lhh@redhat.com --- fence/agents/scsi/fence_scsi.pl | 58 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl index 7fcb685..0512f3e 100644 --- a/fence/agents/scsi/fence_scsi.pl +++ b/fence/agents/scsi/fence_scsi.pl @@ -110,6 +110,62 @@ sub do_action_status ($@) } }
+sub do_verify_on ($@) +{ + my $self = (caller(0))[3]; + my ($node_key, @devices) = @_; + my $count = 0; + + for $dev (@devices) { + my @keys = grep { /^$node_key$/ } get_registration_keys ($dev); + + ## check that our key is registered + if (scalar (@keys) == 0) { + log_debug ("failed to register key $node_key on device $dev"); + $count++; + next; + } + + ## check that a reservation exists + if (!get_reservation_key ($dev)) { + log_debug ("no reservation exists on device $dev"); + $count++; + } + } + + if ($count != 0) { + log_error ("$self: failed to verify $count devices"); + } +} + +sub do_verify_off ($@) +{ + my $self = (caller(0))[3]; + my ($node_key, @devices) = @_; + my $count = 0; + + for $dev (@devices) { + my @keys = grep { /^$node_key$/ } get_registration_keys ($dev); + + ## check that our key is not registered + if (scalar (@keys) != 0) { + log_debug ("failed to remove key $node_key from device $dev"); + $count++; + next; + } + + ## check that a reservation exists + if (!get_reservation_key ($dev)) { + log_debug ("no reservation exists on device $dev"); + $count++; + } + } + + if ($count != 0) { + log_error ("$self: failed to verify $count devices"); + } +} + sub do_register ($$$) { my $self = (caller(0))[3]; @@ -668,9 +724,11 @@ if (!defined $opt_o) { ## if ($opt_o =~ /^on$/i) { do_action_on ($key, @devices); + do_verify_on ($key, @devices); } elsif ($opt_o =~ /^off$/i) { do_action_off ($key, @devices); + do_verify_off ($key, @devices); } elsif ($opt_o =~ /^status/i) { do_action_status ($key, @devices);
cluster-commits@lists.fedorahosted.org