Send Linux-ha-cvs mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."
Today's Topics:
1. Linux-HA CVS: cts by alan from ([email protected])
2. Linux-HA CVS: lib by alan from ([email protected])
3. Linux-HA CVS: lrm by sunjd from ([email protected])
----------------------------------------------------------------------
Message: 1
Date: Wed, 16 Nov 2005 20:26:08 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: cts by alan from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : alan
Host :
Project : linux-ha
Module : cts
Dir : linux-ha/cts
Modified Files:
CTStests.py.in
Log Message:
Put (back?) import of sys module.
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/cts/CTStests.py.in,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -3 -r1.133 -r1.134
--- CTStests.py.in 26 Oct 2005 11:38:03 -0000 1.133
+++ CTStests.py.in 17 Nov 2005 03:26:07 -0000 1.134
@@ -43,7 +43,7 @@
import CTS
from CM_hb import HBConfig
import CTSaudits
-import time, os, re, types, string, tempfile
+import time, os, re, types, string, tempfile, sys
from CTSaudits import *
from stat import *
from xml.dom.minidom import *
------------------------------
Message: 2
Date: Wed, 16 Nov 2005 22:32:31 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by alan from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : alan
Host :
Project : linux-ha
Module : lib
Dir : linux-ha/lib/plugins/stonith/external
Modified Files:
ssh.in
Log Message:
Changed the parameter for the external/ssh hostlist so that it matches
the "expected" hostlist name that all the other ('C') code uses.
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/plugins/stonith/external/ssh.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ssh.in 7 Nov 2005 15:50:18 -0000 1.6
+++ ssh.in 17 Nov 2005 05:32:31 -0000 1.7
@@ -51,7 +51,7 @@
case $1 in
gethosts)
- for h in $ST_HOSTLIST ; do
+ for h in $hostlist ; do
echo $h
done
exit 0
@@ -67,7 +67,7 @@
exit 1
;;
reset)
- for h in $ST_HOSTLIST
+ for h in $hostlist
do
if
[ "$h" != "$2" ]
@@ -89,7 +89,12 @@
exit 1
;;
status)
- for h in $ST_HOSTLIST
+ if
+ [ -z "$hostlist" ]
+ then
+ exit 1
+ fi
+ for h in $hostlist
do
if
host $h 2>&1 | grep "not found:"
@@ -100,7 +105,7 @@
exit 0
;;
getconfignames)
- echo "ST_HOSTLIST"
+ echo "hostlist"
exit 0
;;
getinfo-devid)
@@ -123,7 +128,7 @@
getinfo-xml)
cat << SSHXML
"<parameters>"
-"<parameter name=\"ST_HOSTLIST\" unique=\"1\">"
+"<parameter name=\"hostlist\" unique=\"1\">"
"<content type=\"string\" />"
"<shortdesc lang=\"en\">"
"Hostlist"
------------------------------
Message: 3
Date: Thu, 17 Nov 2005 00:00:27 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lrm by sunjd from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : sunjd
Host :
Project : linux-ha
Module : lrm
Dir : linux-ha/lrm/lrmd
Modified Files:
lrmd.c
Log Message:
The fix for bug756
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lrm/lrmd/lrmd.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -3 -r1.185 -r1.186
--- lrmd.c 15 Nov 2005 01:46:06 -0000 1.185
+++ lrmd.c 17 Nov 2005 07:00:27 -0000 1.186
@@ -1,4 +1,4 @@
-/* $Id: lrmd.c,v 1.185 2005/11/15 01:46:06 zhenh Exp $ */
+/* $Id: lrmd.c,v 1.186 2005/11/17 07:00:27 sunjd Exp $ */
/*
* Local Resource Manager Daemon
*
@@ -203,12 +203,17 @@
pid_t client_id;
int call_id;
int exec_pid;
- int output_fd;
+ char first_line_ra_stdout[80]; /* only for heartbeat RAs */
guint timeout_tag;
guint repeat_timeout_tag;
int interval;
int delay;
struct ha_msg* msg;
+ /* For read the output from RAs */
+ int ra_stdout_fd;
+ int ra_stderr_fd;
+ GFDSource * ra_stdout_gsource;
+ GFDSource * ra_stderr_gsource;
/*time stamp*/
longclock_t t_recv;
longclock_t t_addtolist;
@@ -260,7 +265,9 @@
static lrmd_client_t* lookup_client (pid_t pid);
static lrmd_rsc_t* lookup_rsc (const char* rid);
static lrmd_rsc_t* lookup_rsc_by_msg (struct ha_msg* msg);
-static int read_pipe(int fd, char ** data, void * user_data);
+static int read_pipe(int fd, char ** data, gpointer user_data);
+static gboolean handle_pipe_ra_stdout(int fd, gpointer user_data);
+static gboolean handle_pipe_ra_stderr(int fd, gpointer user_data);
static struct ha_msg* op_to_msg(lrmd_op_t* op);
static gboolean lrm_shutdown(void);
static gboolean can_shutdown(void);
@@ -417,6 +424,24 @@
cl_free(op->rsc_id);
op->rsc_id = NULL;
op->exec_pid = 0;
+ if (op->ra_stdout_fd != -1) {
+ close(op->ra_stdout_fd);
+ op->ra_stdout_fd = -1;
+ }
+ if (op->ra_stderr_fd != -1) {
+ close(op->ra_stderr_fd);
+ op->ra_stderr_fd = -1;
+ }
+ if ( NULL != op->ra_stdout_gsource) {
+ G_main_del_fd(op->ra_stdout_gsource);
+ op->ra_stdout_gsource = NULL;
+ }
+ if ( NULL != op->ra_stderr_gsource) {
+ G_main_del_fd(op->ra_stderr_gsource);
+ op->ra_stderr_gsource = NULL;
+ }
+ memset(op->first_line_ra_stdout, 0, sizeof(op->first_line_ra_stdout));
+
lrmd_debug(LOG_DEBUG, "lrmd_op_destroy: free the op whose address is %p"
, op);
cl_free(op);
@@ -438,6 +463,11 @@
op->exec_pid = -1;
op->timeout_tag = -1;
op->repeat_timeout_tag = -1;
+ op->ra_stdout_fd = -1;
+ op->ra_stderr_fd = -1;
+ op->ra_stdout_gsource = NULL;
+ op->ra_stderr_gsource = NULL;
+ memset(op->first_line_ra_stdout, 0, sizeof(op->first_line_ra_stdout));
op->t_recv = time_longclock();
++lrm_objectstats.opcount;
return op;
@@ -456,6 +486,11 @@
/* Do a "deep" copy of the message structure */
ret->msg = ha_msg_copy(op->msg);
ret->rsc_id = cl_strdup(op->rsc_id);
+ ret->ra_stdout_fd = -1;
+ ret->ra_stderr_fd = -1;
+ ret->ra_stdout_gsource = NULL;
+ ret->ra_stderr_gsource = NULL;
+ memset(ret->first_line_ra_stdout, 0, sizeof(ret->first_line_ra_stdout));
ret->is_copy = TRUE;
return ret;
}
@@ -1011,6 +1046,7 @@
shutdown_in_progress = TRUE;
if (can_shutdown()) {
+
lrm_shutdown();
} else {
lrmd_debug(LOG_DEBUG, "sigterm_action: can't shutdown now.");
@@ -2726,7 +2762,6 @@
&& LRM_OP_CANCELLED != op_status) {
lrmd_op_t* repeat_op = lrmd_op_copy(op);
repeat_op->exec_pid = -1;
- repeat_op->output_fd = -1;
repeat_op->timeout_tag = -1;
repeat_op->is_copy = FALSE;
repeat_op->repeat_timeout_tag =
@@ -2843,7 +2878,8 @@
int
perform_ra_op(lrmd_op_t* op)
{
- int fd[2];
+ int stdout_fd[2];
+ int stderr_fd[2];
pid_t pid;
int timeout;
struct RAExecOps * RAExec = NULL;
@@ -2858,8 +2894,12 @@
rsc = (lrmd_rsc_t*)lookup_rsc(op->rsc_id);
CHECK_ALLOCATED(rsc, "rsc", HA_FAIL);
- if ( pipe(fd) < 0 ) {
- lrmd_log(LOG_ERR,"perform_ra_op:pipe create error.");
+ if ( pipe(stdout_fd) < 0 ) {
+ cl_perror("%s::%d: pipe", __FUNCTION__, __LINE__);
+ }
+
+ if ( pipe(stderr_fd) < 0 ) {
+ cl_perror("%s::%d: pipe", __FUNCTION__, __LINE__);
}
if (op->exec_pid == 0) {
@@ -2904,7 +2944,8 @@
default: /* Parent */
NewTrackedProc(pid, 1, PT_LOGNONE, op,
&ManagedChildTrackOps);
- close(fd[1]);
+ close(stdout_fd[1]);
+ close(stderr_fd[1]);
/*
* No any obviouse proof of lrmd hang in pipe read yet.
* Bug 475 may be a duplicate of bug 499.
@@ -2912,14 +2953,32 @@
* obviously reduce the RA execution time (bug 553).
*/
/* Let the read operation be NONBLOCK */
- if ((flag = fcntl(fd[0], F_GETFL)) >= 0) {
- if (fcntl(fd[0], F_SETFL, flag|O_NONBLOCK) < 0)
{
- cl_perror("perform_ra_op: fcntl");
+ if ((flag = fcntl(stdout_fd[0], F_GETFL)) >= 0) {
+ if (fcntl(stdout_fd[0], F_SETFL,
flag|O_NONBLOCK) < 0) {
+ cl_perror("%s::%d: fcntl", __FUNCTION__
+ , __LINE__);
}
} else {
- cl_perror("perform_ra_op: fcntl");
+ cl_perror("%s::%d: fcntl", __FUNCTION__,
__LINE__);
}
- op->output_fd = fd[0];
+ if ((flag = fcntl(stderr_fd[0], F_GETFL)) >= 0) {
+ if (fcntl(stderr_fd[0], F_SETFL,
flag|O_NONBLOCK) < 0) {
+ cl_perror("%s::%d: fcntl", __FUNCTION__
+ , __LINE__);
+ }
+ } else {
+ cl_perror("%s::%d: fcntl", __FUNCTION__,
__LINE__);
+ }
+
+ op->ra_stdout_fd = stdout_fd[0];
+ op->ra_stderr_fd = stderr_fd[0];
+ op->ra_stdout_gsource = G_main_add_fd(G_PRIORITY_HIGH
+ , stdout_fd[0], FALSE, handle_pipe_ra_stdout
+ , op, NULL);
+ op->ra_stderr_gsource = G_main_add_fd(G_PRIORITY_HIGH
+ , stderr_fd[0], FALSE, handle_pipe_ra_stderr
+ , op, NULL);
+
op->exec_pid = pid;
return_to_dropped_privs();
@@ -2931,13 +2990,22 @@
* need to investigate if it works the same too.
*/
setpgid(0,0);
- close(fd[0]);
- if (STDOUT_FILENO != fd[1]) {
- if (dup2(fd[1], STDOUT_FILENO)!=STDOUT_FILENO) {
- lrmd_log(LOG_ERR,"perform_ra_op: dup2
error.");
+ close(stdout_fd[0]);
+ close(stderr_fd[0]);
+ if (STDOUT_FILENO != stdout_fd[1]) {
+ if (dup2(stdout_fd[1],
STDOUT_FILENO)!=STDOUT_FILENO) {
+ cl_perror("%s::%d: dup2"
+ , __FUNCTION__, __LINE__);
+ }
+ }
+ if (STDERR_FILENO != stderr_fd[1]) {
+ if (dup2(stderr_fd[1],
STDERR_FILENO)!=STDERR_FILENO) {
+ cl_perror("%s::%d: dup2"
+ , __FUNCTION__, __LINE__);
}
}
- close(fd[1]);
+ close(stdout_fd[1]);
+ close(stderr_fd[1]);
RAExec = g_hash_table_lookup(RAExecFuncs,rsc->class);
if (NULL == RAExec) {
lrmd_log(LOG_ERR,"perform_ra_op: can not find
RAExec");
@@ -2982,7 +3050,6 @@
lrmd_rsc_t* rsc = NULL;
struct RAExecOps * RAExec = NULL;
const char* op_type;
- char* data = NULL;
int rc;
int ret;
int op_status;
@@ -3036,22 +3103,17 @@
}
op_type = ha_msg_value(op->msg, F_LRM_OP);
- data = NULL;
- /* We hope we never have to read too much data from a child process */
- /* Or they will hang waiting for us to read and never die :-) */
- ret = read_pipe(op->output_fd, &data, &(p->pid));
- rc = RAExec->map_ra_retvalue(exitcode, op_type, data);
- if (rc != EXECRA_OK || ret != 0) {
+ rc = RAExec->map_ra_retvalue(exitcode, op_type,
op->first_line_ra_stdout);
+ if (rc != EXECRA_OK) {
lrmd_debug(LOG_DEBUG, "A RA execution: process [%d], "
"exitcode %d, with signo %d, %s, the RA output: %s"
, p->pid, exitcode, signo, op_info(op)
- , (data!=NULL)?data:"NULL");
+ , op->first_line_ra_stdout);
}
if (EXECRA_EXEC_UNKNOWN_ERROR == rc || EXECRA_NO_RA == rc) {
if (HA_OK != ha_msg_mod_int(op->msg, F_LRM_OPSTATUS,
LRM_OP_ERROR)) {
LOG_FAILED_TO_ADD_FIELD("opstatus")
- g_free(data);
return ;
}
lrmd_log(LOG_ERR
@@ -3061,25 +3123,22 @@
if (HA_OK != ha_msg_mod_int(op->msg, F_LRM_OPSTATUS,
LRM_OP_DONE)) {
LOG_FAILED_TO_ADD_FIELD("opstatus")
- g_free(data);
return ;
}
if (HA_OK != ha_msg_mod_int(op->msg, F_LRM_RC, rc)) {
LOG_FAILED_TO_ADD_FIELD("F_LRM_RC")
- g_free(data);
return ;
}
}
- if (NULL != data) {
+ if ( 0 < strlen(op->first_line_ra_stdout) ) {
if (NULL != cl_get_string(op->msg, F_LRM_DATA)) {
cl_msg_remove(op->msg, F_LRM_DATA);
}
- ret = ha_msg_add(op->msg, F_LRM_DATA, data);
+ ret = ha_msg_add(op->msg, F_LRM_DATA, op->first_line_ra_stdout);
if (HA_OK != ret) {
LOG_FAILED_TO_ADD_FIELD("data")
}
- g_free(data);
}
on_op_done(op);
@@ -3163,21 +3222,79 @@
return rsc;
}
+
+static gboolean
+handle_pipe_ra_stdout(int fd, gpointer user_data)
+{
+ static gboolean first_line = TRUE;
+ gboolean rc = TRUE;
+ lrmd_op_t* op = (lrmd_op_t *)user_data;
+ const char* op_type = NULL;
+ char * data = NULL;
+
+ if (0 != read_pipe(fd, &data, op)) {
+ rc = FALSE;
+ }
+ if (data!=NULL) {
+ op_type = ha_msg_value(op->msg, F_LRM_OP);
+ if ( (0==STRNCMP_CONST(op_type, "meta-data"))
+ ||(0==STRNCMP_CONST(op_type, "monitor"))
+ ||(0==STRNCMP_CONST(op_type, "status")) ) {
+ lrmd_debug(LOG_DEBUG, "RA output: (%s:%s:stdout) %s"
+ , op->rsc_id, op_type, data);
+ } else {
+ lrmd_log(LOG_INFO, "RA output: (%s:%s:stdout) %s"
+ , op->rsc_id, op_type, data);
+ }
+ if (first_line == TRUE) {
+ memset(op->first_line_ra_stdout, 0
+ , sizeof(op->first_line_ra_stdout));
+ strncpy(op->first_line_ra_stdout, data
+ , sizeof(op->first_line_ra_stdout) - 1);
+ first_line = FALSE;
+ }
+ g_free(data);
+ }
+
+ return rc;
+}
+
+static gboolean
+handle_pipe_ra_stderr(int fd, gpointer user_data)
+{
+ gboolean rc = TRUE;
+ lrmd_op_t* op = (lrmd_op_t *)user_data;
+ const char* op_type = NULL;
+ char * data = NULL;
+
+ if (0 != read_pipe(fd, &data, op)) {
+ rc = FALSE;
+ }
+ if (data!=NULL) {
+ op_type = ha_msg_value(op->msg, F_LRM_OP);
+ lrmd_log(LOG_INFO, "RA output: (%s:%s:stderr) %s", op->rsc_id
+ , op_type, data);
+ g_free(data);
+ }
+
+ return rc;
+}
+
int
read_pipe(int fd, char ** data, void * user_data)
{
const int BUFFLEN = 81;
- int rc = 0;
- int pid = *(int *) user_data;
char buffer[BUFFLEN];
int readlen;
GString * gstr_tmp;
+ int rc = 0;
+ lrmd_rsc_t* rsc = NULL;
+ lrmd_op_t* op = (lrmd_op_t *)user_data;
*data = NULL;
gstr_tmp = g_string_new("");
/* the log is only for analysing bug 475, or should remove it. */
- lrmd_debug(LOG_DEBUG, "read_pipe: begin to read.");
do {
errno = 0;
readlen = read(fd, buffer, BUFFLEN - 1);
@@ -3186,26 +3303,33 @@
g_string_append(gstr_tmp, buffer);
}
} while (readlen == BUFFLEN - 1 || errno == EINTR);
- close(fd);
- if ((readlen < 0) ) {
+ if (errno == EINTR) {
+ errno = 0;
+ }
+ if ((readlen < 0) && (errno !=0)) {
+ rc = -1;
+ if (errno != EAGAIN) {
+ cl_perror("%s::%d errno=%d, read"
+ , __FUNCTION__, __LINE__, errno);
+ }
+
if (errno == EAGAIN) {
- lrmd_log(LOG_ERR, "Process %d failed to redirect stdout
"
- "for its background child (daemon) processes. "
- "This will likely cause those processes to die "
- "mysteriously at some later time (terminated by
"
- "signal SIGPIPE)."
- , pid);
- } else {
- cl_perror("read_pipe: read error");
+ rsc = lookup_rsc(op->rsc_id);
+ lrmd_log(LOG_ERR, "RA %s:%s (process %d) failed to "
+ "redirect %s for its background child (daemon) "
+ "processes. This will likely cause those "
+ "processes to die mysteriously at some later "
+ "time (terminated by signal SIGPIPE)."
+ , (rsc!=NULL)?rsc->class:"<NULL>"
+ , (rsc!=NULL)?rsc->type:"<NULL>"
+ , op->exec_pid
+ , (op->ra_stdout_fd==fd)?"stdout":"stderr");
}
- rc = -1;
}
/* the log is only for analysing bug 475, or should remove it. */
- lrmd_debug(LOG_DEBUG, "read_pipe: finished the pipe read.");
if ( gstr_tmp->len == 0 ) {
- lrmd_debug(LOG_DEBUG, "read_pipe: read 0 byte from this pipe.");
g_string_free(gstr_tmp, TRUE);
} else {
*data = gstr_tmp->str;
@@ -3302,12 +3426,15 @@
char buffer_tmp[80];
GString * str = (GString *)user_data;
- g_snprintf(buffer_tmp, sizeof(buffer_tmp), "%s=%s "
+ g_snprintf(buffer_tmp, sizeof(buffer_tmp), "%s=[%s] "
, (char *)key, (char *)value);
str = g_string_append(str, buffer_tmp);
}
/*
* $Log: lrmd.c,v $
+ * Revision 1.186 2005/11/17 07:00:27 sunjd
+ * The fix for bug756
+ *
* Revision 1.185 2005/11/15 01:46:06 zhenh
* change the way of logger to make BEAM happy
*
------------------------------
_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
End of Linux-ha-cvs Digest, Vol 24, Issue 56
********************************************