Skip to content

Commit

Permalink
Fix: tools: restore crmadmin default timeout to 30 seconds
Browse files Browse the repository at this point in the history
Regression introduced in 2.1.5 via a6ec43e

That commit switched to using synchronous (blocking) IPC when timeout
was set to 0 (the default, which previously meant use 30s). That was
a change in behavior that was a bad idea if someone is calling it in a
script.

This still allows the user to explicitly specify --timeout=0 to get the
blocking behavior.
  • Loading branch information
kgaillot committed Oct 17, 2024
1 parent e496779 commit 6506a0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions tools/crmadmin.8.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ crmadmin [options] [node]

/the Pacemaker controller/
.SH OPTIONS

/query information/
.SH NOTES
25 changes: 14 additions & 11 deletions tools/crmadmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct {
char *ipc_name;
gboolean bash_export;
} options = {
.timeout = 30000, // Default to 30 seconds
.optarg = NULL,
.ipc_name = NULL,
.bash_export = FALSE
Expand Down Expand Up @@ -80,9 +81,10 @@ static GOptionEntry command_options[] = {

static GOptionEntry additional_options[] = {
{ "timeout", 't', 0, G_OPTION_ARG_CALLBACK, command_cb,
"Time to wait before declaring the operation"
"\n failed",
"TIMESPEC"
"Time to wait before declaring the operation"
"\n "
"failed (default 30s; use 0 to disable timeout)",
"DURATION"
},
{ "bash-export", 'B', 0, G_OPTION_ARG_NONE, &options.bash_export,
"Display nodes as shell commands of the form 'export uname=uuid'"
Expand Down Expand Up @@ -131,17 +133,18 @@ static pcmk__supported_format_t formats[] = {
{ NULL, NULL, NULL }
};

#define DESC \
"Notes:\n\n" \
"DURATION in any command line option can be specified as an integer\n" \
"number of seconds, an integer plus units (ms, msec, us, usec, s, sec,\n" \
"m, min, h, or hr), or an ISO 8601 period specification.\n\n" \
"Report bugs to " PCMK__BUG_URL


static GOptionContext *
build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) {
GOptionContext *context = NULL;

const char *description = "Notes:\n\n"
"Time Specification:\n\n"
"The TIMESPEC in any command line option can be specified in many different\n"
"formats. It can be just an integer number of seconds, a number plus units\n"
"(ms/msec/us/usec/s/sec/m/min/h/hr), or an ISO 8601 period specification.\n\n"
"Report bugs to " PCMK__BUG_URL;

GOptionEntry extra_prog_entries[] = {
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &(args->quiet),
"Display only the essential query information",
Expand All @@ -151,7 +154,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) {
};

context = pcmk__build_arg_context(args, "text (default), xml", group, NULL);
g_option_context_set_description(context, description);
g_option_context_set_description(context, DESC);

/* Add the -q option, which cannot be part of the globally supported options
* because some tools use that flag for something else.
Expand Down

0 comments on commit 6506a0b

Please sign in to comment.