Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 315578 Details for
Bug 455326
Feature Request: timeout on start/stop actions
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Pass 2 - includes patch from Ryan O'Hara
BZ_455326-1.patch (text/plain), 4.11 KB, created by
Lon Hohberger
on 2008-09-02 18:57:38 UTC
(
hide
)
Description:
Pass 2 - includes patch from Ryan O'Hara
Filename:
MIME Type:
Creator:
Lon Hohberger
Created:
2008-09-02 18:57:38 UTC
Size:
4.11 KB
patch
obsolete
>diff --git a/rgmanager/include/reslist.h b/rgmanager/include/reslist.h >index 0bb85cf..059d433 100644 >--- a/rgmanager/include/reslist.h >+++ b/rgmanager/include/reslist.h >@@ -45,6 +45,7 @@ > #define RF_DESTROY (1<<8) /** Resource rule flag: Destroy this > resource class if you delete it from > the configuration */ >+#define RF_ENFORCE_TIMEOUTS (1<<9) /** Enforce timeouts for this node */ > > > >diff --git a/rgmanager/src/daemons/restree.c b/rgmanager/src/daemons/restree.c >index d08bdb0..aea9072 100644 >--- a/rgmanager/src/daemons/restree.c >+++ b/rgmanager/src/daemons/restree.c >@@ -334,6 +334,26 @@ restore_signals(void) > } > > >+/** Find the index for a given operation / depth in a resource node */ >+int >+res_act_index(resource_node_t *node, const char *op_str, int depth) >+{ >+ int x = 0; >+ resource_act_t *act; >+ >+ for (x = 0; node->rn_actions[x].ra_name; x++) { >+ act = &node->rn_actions[x]; >+ if (depth != act->ra_depth) >+ continue; >+ if (strcasecmp(act->ra_name, op_str)) >+ continue; >+ return x; >+ } >+ >+ return -1; >+} >+ >+ > /** > Execute a resource-specific agent for a resource node in the tree. > >@@ -348,6 +368,8 @@ res_exec(resource_node_t *node, int op, const char *arg, int depth) > { > int childpid, pid; > int ret = 0; >+ int act_index; >+ time_t sleeptime = 0; > char **env = NULL; > resource_t *res = node->rn_resource; > const char *op_str = agent_op_str(op); >@@ -356,6 +378,17 @@ res_exec(resource_node_t *node, int op, const char *arg, int depth) > if (!res->r_rule->rr_agent) > return 0; > >+ /* Get the action index for later */ >+ act_index = res_act_index(node, op_str, depth); >+ >+ /* This shouldn't happen, but execing an action for which >+ we have an incorrect depth or no status action does not >+ indicate a problem. This allows people writing resource >+ agents to write agents which have no status/monitor function >+ at their option, in violation of the OCF RA API specification. */ >+ if (act_index < 0) >+ return 0; >+ > #ifdef DEBUG > env = build_env(node, depth, node->rn_resource->r_incarnations); > if (!env) >@@ -411,11 +444,53 @@ res_exec(resource_node_t *node, int op, const char *arg, int depth) > kill_env(env); > #endif > >- do { >- pid = waitpid(childpid, &ret, 0); >- if ((pid < 0) && (errno == EINTR)) >- continue; >- } while (0); >+ if (node->rn_flags & RF_ENFORCE_TIMEOUTS) >+ sleeptime = node->rn_actions[act_index].ra_timeout; >+ >+ if (sleeptime > 0) { >+ >+ /* There's a better way to do this, but this is easy and >+ doesn't introduce signal woes */ >+ while (sleeptime) { >+ pid = waitpid(childpid, &ret, WNOHANG); >+ >+ if (pid == childpid) >+ break; >+ sleep(1); >+ --sleeptime; >+ } >+ >+ if (pid != childpid && sleeptime == 0) { >+ >+ clulog(LOG_ERR, >+ "%s on %s:%s timed out after %d seconds\n", >+ op_str, res->r_rule->rr_type, >+ res->r_attrs->ra_value, >+ node->rn_actions[act_index].ra_timeout, >+ ocf_strerror(ret)); >+ >+ /* This can't be guaranteed to kill even the child >+ process if the child is in disk-wait :( */ >+ kill(childpid, SIGKILL); >+ sleep(1); >+ pid = waitpid(childpid, &ret, WNOHANG); >+ if (pid == 0) { >+ clulog(LOG_ERR, >+ "Task %s PID %d did not exit " >+ "after SIGKILL\n", >+ op_str, childpid); >+ } >+ >+ /* Always an error if we time out */ >+ return 1; >+ } >+ } else { >+ do { >+ pid = waitpid(childpid, &ret, 0); >+ if ((pid < 0) && (errno == EINTR)) >+ continue; >+ } while (0); >+ } > > if (WIFEXITED(ret)) { > >@@ -573,6 +648,17 @@ do_load_resource(int ccsfd, char *base, > free(ref); > } > >+ snprintf(tok, sizeof(tok), "%s/@__enforce_timeouts", base); >+#ifndef NO_CCS >+ if (ccs_get(ccsfd, tok, &ref) == 0) { >+#else >+ if (conf_get(tok, &ref) == 0) { >+#endif >+ if (atoi(ref) > 0 || strcasecmp(ref, "yes") == 0) >+ node->rn_flags |= RF_ENFORCE_TIMEOUTS; >+ free(ref); >+ } >+ > curres->r_refs++; > > *newnode = node; >@@ -849,6 +935,8 @@ _print_resource_tree(resource_node_t **tree, int level) > printf("COMMON "); > if (node->rn_flags & RF_INDEPENDENT) > printf("INDEPENDENT "); >+ if (node->rn_flags & RF_ENFORCE_TIMEOUTS) >+ printf("ENFORCE-TIMEOUTS "); > printf("]"); > } > printf(" {\n");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 455326
: 315578