cluster: RHEL6 - fence_scsi: verify that on/off actions succeed

rohara rohara at fedoraproject.org
Tue Jan 25 16:01:39 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a9dd0bb396423ac45120f01bfbe62225eb3d5cd7
Commit:        a9dd0bb396423ac45120f01bfbe62225eb3d5cd7
Parent:        3a8e770b5466fa477a98c6e010babe96fbab0bd1
Author:        Ryan O'Hara <rohara at redhat.com>
AuthorDate:    Mon Jan 24 13:54:25 2011 -0600
Committer:     Ryan O'Hara <rohara at redhat.com>
CommitterDate: Tue Jan 25 10:00:31 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 at redhat.com>
Reviewed-by: Lon Hohberger <lhh at 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 5156881..efeeba3 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);


More information about the cluster-commits mailing list