cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 2/2] fence_scsi: verify that on/off actions succeed
@ 2011-01-24 19:56 Ryan O'Hara
  2011-01-24 20:50 ` Lon Hohberger
  0 siblings, 1 reply; 2+ messages in thread
From: Ryan O'Hara @ 2011-01-24 19:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH 2/2] fence_scsi: verify that on/off actions succeed
  2011-01-24 19:56 [Cluster-devel] [PATCH 2/2] fence_scsi: verify that on/off actions succeed Ryan O'Hara
@ 2011-01-24 20:50 ` Lon Hohberger
  0 siblings, 0 replies; 2+ messages in thread
From: Lon Hohberger @ 2011-01-24 20:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

ACK

-- Lon




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-24 20:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24 19:56 [Cluster-devel] [PATCH 2/2] fence_scsi: verify that on/off actions succeed Ryan O'Hara
2011-01-24 20:50 ` Lon Hohberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).