This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: RHEL5 - fence: IPMI over lan timeout adjusted andconfigurable


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=939d92663e2e3a15d85ededc93e9bdbc9914cee2
Commit:        939d92663e2e3a15d85ededc93e9bdbc9914cee2
Parent:        1198fd8a342ad252273585aadc72f03f16e706d9
Author:        Jan Friesse <jfriesse@redhat.com>
AuthorDate:    Fri Nov 21 15:04:37 2008 +0100
Committer:     Jan Friesse <jfriesse@redhat.com>
CommitterDate: Fri Nov 21 15:04:37 2008 +0100

fence: IPMI over lan timeout adjusted and configurable

This patch adjust timeout to default value 10s which
should be enough for most today IPMI implementations.
It also removes retries, because this job is done
by fenced.

Because some devices still need longer timeouts,
timeout is adjustable by parameter -t (or timeout for stdin
and XML configuration).

rhbz#276541
---
 fence/agents/ipmilan/ipmilan.c |   50 ++++++++++++++++++++--------------------
 fence/man/fence_ipmilan.8      |   10 ++++++++
 2 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 605a8ef..9dde74a 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -52,6 +52,8 @@ do { \
 #define ST_POWEROFF 2
 #define ST_GENERIC_RESET 3
 
+#define DEFAULT_TIMEOUT 10
+
 #define log(lvl, fmt, args...) fprintf(stderr, fmt, ##args)
 #include <libgen.h>
 
@@ -93,6 +95,7 @@ struct ipmi {
 	int i_config;
 	int i_verbose;
 	int i_lanplus;
+	int i_timeout;
 };
 
 
@@ -310,42 +313,25 @@ static int
 ipmi_op(struct ipmi *ipmi, int op, struct Etoken *toklist)
 {
 	char cmd[2048];
-	int retries = 5; 
 	int ret;
 
 	build_cmd(cmd, sizeof(cmd), ipmi, op);
 
 	if (ipmi_spawn(ipmi, cmd) != 0)
 		return -1;
-	ret = ipmi_expect(ipmi, toklist, 120);
+	ret = ipmi_expect(ipmi, toklist, ipmi->i_timeout);
 	ipmi_reap(ipmi);
 
-	while ((ret == EAGAIN || ret == ETIMEDOUT) && retries > 0) {
-		dbg_printf(ipmi, 3, "Sleeping 5 ...\n");
-		sleep(5);
-		dbg_printf(ipmi, 1, "Retrying ...\n");
-		--retries;
-		
-		if (ipmi_spawn(ipmi, cmd) != 0)
-			return -1;
-		ret = ipmi_expect(ipmi, toklist, 120);
-		if (ret == EFAULT) {
-			/* Doomed. */
-			break;
-		}
-		ipmi_reap(ipmi);
-	}
-
 	if (ret == EFAULT) {
 		log(LOG_CRIT, "ipmilan: ipmitool failed to create "
 		    "mutex; unable to complete operation\n");
 		return ret;
 	}
 
-	if (ret == EAGAIN) {
+	if (ret == ETIMEDOUT) {
 		/*!!! Still couldn't get through?! */
 		log(LOG_WARNING,
-		    "ipmilan: Failed to connect after 30 seconds\n");
+		    "ipmilan: Failed to connect after %d seconds\n",ipmi->i_timeout);
 	}
 
 	return ret;
@@ -466,7 +452,7 @@ ipmi_destroy(struct ipmi *i)
  */
 static struct ipmi *
 ipmi_init(struct ipmi *i, char *host, char *authtype,
-	  char *user, char *password, int lanplus, int verbose)
+	  char *user, char *password, int lanplus, int verbose,int timeout)
 {
 	const char *p;
 
@@ -537,6 +523,7 @@ ipmi_init(struct ipmi *i, char *host, char *authtype,
 	i->i_id = IPMIID;
 	i->i_verbose = verbose;
 	i->i_lanplus = lanplus;
+	i->i_timeout = timeout;
 
 	return i;
 }
@@ -821,7 +808,7 @@ get_options_stdin(char *ip, size_t iplen,
 		  char *pwd_script, size_t pwd_script_len,
 		  char *user, size_t userlen,
 		  char *op, size_t oplen,
-		  int *lanplus, int *verbose)
+		  int *lanplus, int *verbose,int *timeout)
 {
 	char in[256];
 	int line = 0;
@@ -883,6 +870,10 @@ get_options_stdin(char *ip, size_t iplen,
 				user[0] = 0;
 		} else if (!strcasecmp(name, "lanplus")) {
 			(*lanplus) = 1;
+		} else if (!strcasecmp(name,"timeout")) {
+			if ((sscanf(val,"%d",timeout)!=1) || *timeout<1) {
+			    *timeout=DEFAULT_TIMEOUT;
+			}
 		} else if (!strcasecmp(name, "option") ||
 			   !strcasecmp(name, "operation") ||
 			   !strcasecmp(name, "action")) {
@@ -922,6 +913,7 @@ printf("   -l <login>     Username/Login (if required) to control power\n"
        "                  on IPMI device\n");
 printf("   -o <op>        Operation to perform.\n");
 printf("                  Valid operations: on, off, reboot, status\n");
+printf("   -t <timeout>   Timeout (sec) for IPMI operation (default %d)\n",DEFAULT_TIMEOUT);
 printf("   -V             Print version and exit\n");
 printf("   -v             Verbose mode\n\n");
 printf("If no options are specified, the following options will be read\n");
@@ -935,6 +927,7 @@ printf("   login=<login>         Same as -u\n");
 printf("   option=<op>           Same as -o\n");
 printf("   operation=<op>        Same as -o\n");
 printf("   action=<op>           Same as -o\n");
+printf("   timeout=<timeout>     Same as -t\n");
 printf("   verbose               Same as -v\n\n");
 	exit(1);
 }
@@ -955,6 +948,7 @@ main(int argc, char **argv)
 	int verbose=0;
 	char *pname = basename(argv[0]);
 	struct ipmi *i;
+	int timeout=DEFAULT_TIMEOUT;
 
 	memset(ip, 0, sizeof(ip));
 	memset(authtype, 0, sizeof(authtype));
@@ -966,7 +960,7 @@ main(int argc, char **argv)
 		/*
 		   Parse command line options if any were specified
 		 */
-		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hH")) != EOF) {
+		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:")) != EOF) {
 			switch(opt) {
 			case 'A':
 				/* Auth type */
@@ -996,6 +990,12 @@ main(int argc, char **argv)
 				/* Operation */
 				strncpy(op, optarg, sizeof(op));
 				break;
+			case 't':
+				/* Timeout */
+				if ((sscanf(optarg,"%d",&timeout)!=1) || timeout<1) {
+				    fail_exit("Timeout option expects positive number parameter");
+				}
+				break;
 			case 'v':
 				verbose++;
 				break;
@@ -1019,7 +1019,7 @@ main(int argc, char **argv)
 				      passwd, sizeof(passwd),
 					  pwd_script, sizeof(pwd_script),
 				      user, sizeof(user),
-				      op, sizeof(op), &lanplus, &verbose) != 0)
+				      op, sizeof(op), &lanplus, &verbose,&timeout) != 0)
 			return 1;
 	}
 
@@ -1069,7 +1069,7 @@ main(int argc, char **argv)
 
 
 	/* Ok, set up the IPMI struct */
-	i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose);
+	i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout);
 	if (!i)
 		fail_exit("Failed to initialize\n");
 
diff --git a/fence/man/fence_ipmilan.8 b/fence/man/fence_ipmilan.8
index 96e9713..822b827 100644
--- a/fence/man/fence_ipmilan.8
+++ b/fence/man/fence_ipmilan.8
@@ -48,6 +48,11 @@ Use the lanplus option if this is a lanplus capable interface (for example iLo2)
 \fB-A\fP \fIAuthentication Type\fP
 Can be set to none, password, md2, or md5.
 .TP
+\fB-t\fP \fItimeout\fP
+Timeout in seconds for IPMI operation. Default is 10, but in some cases it
+must be set to higher value (anything above 30 is not recommended and may
+cause strange problems).
+.TP
 \fB-q\fP
 Quiet operation.  Only print out error messages.
 .TP
@@ -74,6 +79,11 @@ Password (if required) for login.
 \fIauth = < param >\fR
 Authentication type (none, password, md2, md5).
 .TP
+\fItimeout = < param >\fR
+Timeout in seconds for IPMI operation. Default is 10, but in some cases it
+must be set to higher value (anything above 30 is not recommended and may
+cause strange problems).
+.TP
 \fIlanplus\fR
 If we are using the lanplus option for ipmitool
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]