[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH 2/2] 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>
---
 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..2bc05df 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);
-- 
1.7.3.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]