Permalink
Browse files

Implements EUCA-3596. New fault to report failed iscsiadm attempt.

Storage related operations fail when iscsiadm commands error out and complain that iSCSI driver is not available.
This may have been caued by iscsi_tcp or other iSCSI kernel modules that were not loaded/got unloaded due to an unknown reason.
Implemented a new fault conforming to the troubleshooting framework to record these failues.
Fault gets logged to either sc-fault.log or nc-fault.log depending on which eucalyptus component initiated it.
  • Loading branch information...
1 parent 3ed69f4 commit 4df7d594bbe40b6f9156fb819eee53b6bedcbdb1 Swathi Gangisetty committed Oct 4, 2012
@@ -70,6 +70,9 @@ BEGIN
use lib $script_dir;
+## Initialize global variables for handling faults
+$euca_component = "NC";
+
require "iscsitarget_common.pl";
require "connect_iscsitarget_main.pl";
##################################################################
@@ -70,6 +70,9 @@ BEGIN
use lib $script_dir;
+## Initialize global variables for handling faults
+$euca_component = "SC";
+
require "iscsitarget_common.pl";
$OPENSSL = untaint(`which openssl`);
@@ -70,5 +70,8 @@ BEGIN
use lib $script_dir;
+## Initialize global variables for handling faults
+$euca_component = "NC";
+
require "iscsitarget_common.pl";
require "disconnect_iscsitarget_main.pl";
View
No changes.
@@ -70,5 +70,8 @@ BEGIN
use lib $script_dir;
+## Initialize global variables for handling faults
+$euca_component = "SC";
+
require "iscsitarget_common.pl";
require "disconnect_iscsitarget_main.pl";
View
20 tools/iscsitarget_common.pl 100644 → 100755
@@ -71,6 +71,9 @@
$DELIMITER = ",";
+$ERROR_CAUSE = "iscsiadm";
+$ERROR_MESSAGE = "iSCSI driver not found";
+
sub parse_devstring {
my ($dev_string) = @_;
return split($DELIMITER, $dev_string);
@@ -87,12 +90,29 @@ sub run_cmd {
my ($print_on_error, $exit_on_error, $command) = @_;
my @outlines = qx($command 2>&1);
if ($? != 0) {
+ check_and_log_fault($command, @outlines);
$print_on_error and print STDERR "Failed to run '$command': @outlines";
$exit_on_error and do_exit(1);
}
return @outlines;
}
+sub check_and_log_fault {
+ my ($command, @output) = @_;
+
+ if (!is_null_or_empty($euca_home) && !is_null_or_empty($euca_component) && ($command =~ /\Q$ERROR_CAUSE\E/i)) {
+ my $FAULT_GEN_CMD = $euca_home."/usr/sbin/euca-generate-fault -c ".lc($euca_component)." 2001 component ".$euca_component;
+
+ foreach (@output) {
+ chomp;
+ if(/\Q$ERROR_MESSAGE\E/i) {
+ qx($FAULT_GEN_CMD 2>&1);
+ last;
+ }
+ }
+ }
+}
+
sub do_exit {
$e = shift;
exit($e);
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2012 Eucalyptus Systems, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see http://www.gnu.org/licenses/.
+
+ Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
+ CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
+ additional information or have any questions.
+ -->
+<eucafaults version="1" description="Templates for the fault subsystem">
+ <fault
+ id="2001"
+ message="iscsiadm command is failing">
+
+ <condition
+ message="Volume operation (attach/detach/snapshot) failed to complete"/>
+
+ <cause
+ message="iSCSI driver not found"/>
+
+ <initiator
+ message="${component}"/>
+
+ <location
+ message="open iSCSI on ${component}"/>
+
+ <resolution>
+ <message>
+ 1) Load all iSCSI kernel modules
+
+ 2) Restart iscsid service
+
+ 3) Run iscsiadm and check the output
+
+ 4) Please fix this file!
+ </message>
+ </resolution>
+ </fault>
+</eucafaults>

0 comments on commit 4df7d59

Please sign in to comment.