Skip to content

Commit c26c995

Browse files
committed
Feature: crmadmin: tweaks
- use seconds for timeout, and support ISO 8601 duration - update cts tests to use seconds - update -S output to "Controller on NODE in state FSA_STATE: HEALTH_STATUS" - add example value for parameters to help text - remove --election/--kill parameters
1 parent a4892cc commit c26c995

File tree

5 files changed

+31
-93
lines changed

5 files changed

+31
-93
lines changed

Diff for: cts/patterns.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, name):
2626
self.BadNews = []
2727
self.components = {}
2828
self.commands = {
29-
"StatusCmd" : "crmadmin -t 60000 -S %s 2>/dev/null",
29+
"StatusCmd" : "crmadmin -t 60 -S %s 2>/dev/null",
3030
"CibQuery" : "cibadmin -Ql",
3131
"CibAddXml" : "cibadmin --modify -c --xml-text %s",
3232
"CibDelXpath" : "cibadmin --delete --xpath %s",

Diff for: include/pcmki/pcmki_cluster_queries.h

-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@ int pcmk__controller_status(pcmk__output_t *out, char *dest_node, guint message_
99
int pcmk__designated_controller(pcmk__output_t *out, guint message_timeout_ms);
1010
int pcmk__pacemakerd_status(pcmk__output_t *out, char *ipc_name, guint message_timeout_ms);
1111
int pcmk__list_nodes(pcmk__output_t *out, char *node_types, gboolean BASH_EXPORT);
12-
13-
// remove when parameters removed from tools/crmadmin.c
14-
int pcmk__shutdown_controller(pcmk__output_t *out, char *dest_node);
15-
int pcmk__start_election(pcmk__output_t *out);

Diff for: lib/pacemaker/pcmk_cluster_queries.c

-46
Original file line numberDiff line numberDiff line change
@@ -497,49 +497,3 @@ pcmk_list_nodes(xmlNodePtr *xml, char *node_types)
497497
pcmk__out_epilogue(out, xml, rc);
498498
return rc;
499499
}
500-
501-
// remove when parameters removed from tools/crmadmin.c
502-
int
503-
pcmk__shutdown_controller(pcmk__output_t *out, char *dest_node)
504-
{
505-
data_t data = {
506-
.out = out,
507-
.mainloop = NULL,
508-
.rc = pcmk_rc_ok,
509-
};
510-
pcmk_ipc_api_t *controld_api = ipc_connect(&data, pcmk_ipc_controld, NULL);
511-
512-
if (controld_api != NULL) {
513-
int rc = pcmk_controld_api_shutdown(controld_api, dest_node);
514-
if (rc != pcmk_rc_ok) {
515-
out->err(out, "error: Command failed: %s", pcmk_rc_str(rc));
516-
data.rc = rc;
517-
}
518-
pcmk_free_ipc_api(controld_api);
519-
}
520-
521-
return data.rc;
522-
}
523-
524-
int
525-
pcmk__start_election(pcmk__output_t *out)
526-
{
527-
data_t data = {
528-
.out = out,
529-
.mainloop = NULL,
530-
.rc = pcmk_rc_ok,
531-
};
532-
pcmk_ipc_api_t *controld_api = ipc_connect(&data, pcmk_ipc_controld, NULL);
533-
534-
if (controld_api != NULL) {
535-
int rc = pcmk_controld_api_start_election(controld_api);
536-
if (rc != pcmk_rc_ok) {
537-
out->err(out, "error: Command failed: %s", pcmk_rc_str(rc));
538-
data.rc = rc;
539-
}
540-
541-
pcmk_free_ipc_api(controld_api);
542-
}
543-
544-
return data.rc;
545-
}

Diff for: lib/pacemaker/pcmk_output.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,14 @@ PCMK__OUTPUT_ARGS("health", "const char *", "const char *", "const char *", "con
376376
static int
377377
health_text(pcmk__output_t *out, va_list args)
378378
{
379-
const char *sys_from = va_arg(args, const char *);
379+
const char *sys_from G_GNUC_UNUSED = va_arg(args, const char *);
380380
const char *host_from = va_arg(args, const char *);
381381
const char *fsa_state = va_arg(args, const char *);
382382
const char *result = va_arg(args, const char *);
383383

384384
if (!out->is_quiet(out)) {
385-
out->info(out, "Status of %s@%s: %s (%s)", crm_str(sys_from),
386-
crm_str(host_from), crm_str(fsa_state), crm_str(result));
385+
out->info(out, "Controller on %s in state %s: %s", crm_str(host_from),
386+
crm_str(fsa_state), crm_str(result));
387387
} else if (fsa_state != NULL) {
388388
out->info(out, "%s", fsa_state);
389389
}

Diff for: tools/crmadmin.c

+27-39
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525

2626
static enum {
2727
cmd_none,
28-
cmd_shutdown,
2928
cmd_health,
30-
cmd_elect_dc,
3129
cmd_whois_dc,
3230
cmd_list_nodes,
3331
cmd_pacemakerd_health,
@@ -50,36 +48,28 @@ gboolean command_cb(const gchar *option_name, const gchar *optarg, gpointer data
5048
static GOptionEntry command_options[] = {
5149
{ "status", 'S', 0, G_OPTION_ARG_CALLBACK, command_cb,
5250
"Display the status of the specified node."
53-
"\n Result is state of node's internal finite state"
54-
"\n machine, which can be useful for debugging",
55-
NULL
51+
"\n Result is state of node's internal finite state"
52+
"\n machine, which can be useful for debugging",
53+
"NODE"
5654
},
5755
{ "pacemakerd", 'P', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, command_cb,
5856
"Display the status of local pacemakerd."
59-
"\n Result is the state of the sub-daemons watched"
60-
"\n by pacemakerd.",
57+
"\n Result is the state of the sub-daemons watched"
58+
"\n by pacemakerd.",
6159
NULL
6260
},
6361
{ "dc_lookup", 'D', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, command_cb,
6462
"Display the uname of the node co-ordinating the cluster."
65-
"\n This is an internal detail rarely useful to"
66-
"\n administrators except when deciding on which"
67-
"\n node to examine the logs.",
63+
"\n This is an internal detail rarely useful to"
64+
"\n administrators except when deciding on which"
65+
"\n node to examine the logs.",
6866
NULL
6967
},
7068
{ "nodes", 'N', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, command_cb,
7169
"Display the uname of all member nodes [optionally filtered by type (comma-separated)]"
72-
"\n Types: all (default), cluster, guest, remote",
70+
"\n Types: all (default), cluster, guest, remote",
7371
"TYPE"
7472
},
75-
{ "election", 'E', G_OPTION_FLAG_HIDDEN|G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, command_cb,
76-
"(Advanced) Start an election for the cluster co-ordinator",
77-
NULL
78-
},
79-
{ "kill", 'K', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, command_cb,
80-
"(Advanced) Stop controller (not rest of cluster stack) on specified node",
81-
NULL
82-
},
8373
{ "health", 'H', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &options.health,
8474
NULL,
8575
NULL
@@ -89,18 +79,18 @@ static GOptionEntry command_options[] = {
8979
};
9080

9181
static GOptionEntry additional_options[] = {
92-
{ "timeout", 't', 0, G_OPTION_ARG_INT, &options.timeout,
93-
"Time (in milliseconds) to wait before declaring the"
94-
"\n operation failed",
95-
NULL
82+
{ "timeout", 't', 0, G_OPTION_ARG_CALLBACK, command_cb,
83+
"Time to wait before declaring the operation"
84+
"\n failed",
85+
"TIMESPEC"
9686
},
9787
{ "bash-export", 'B', 0, G_OPTION_ARG_NONE, &options.BASH_EXPORT,
9888
"Display nodes as shell commands of the form 'export uname=uuid'"
99-
"\n (valid with -N/--nodes)",
89+
"\n (valid with -N/--nodes)",
10090
},
10191
{ "ipc-name", 'i', 0, G_OPTION_ARG_STRING, &options.ipc_name,
10292
"Name to use for ipc instead of 'crmadmin' (with -P/--pacemakerd).",
103-
NULL
93+
"NAME"
10494
},
10595

10696
{ NULL }
@@ -126,13 +116,12 @@ command_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError
126116
command = cmd_list_nodes;
127117
}
128118

129-
if (!strcmp(option_name, "--election") || !strcmp(option_name, "-E")) {
130-
command = cmd_elect_dc;
131-
}
132-
133-
if (!strcmp(option_name, "--kill") || !strcmp(option_name, "-K")) {
134-
command = cmd_shutdown;
135-
crm_trace("Option %c => %s", 'K', optarg);
119+
if (!strcmp(option_name, "--timeout") || !strcmp(option_name, "-t")) {
120+
options.timeout = crm_parse_interval_spec(optarg);
121+
if (errno == EINVAL) {
122+
return FALSE;
123+
}
124+
return TRUE;
136125
}
137126

138127
if (optarg) {
@@ -155,7 +144,12 @@ static GOptionContext *
155144
build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) {
156145
GOptionContext *context = NULL;
157146

158-
const char *description = "Report bugs to users@clusterlabs.org";
147+
const char *description = "Notes:\n\n"
148+
"Time Specification:\n\n"
149+
"The TIMESPEC in any command line option can be specified in many different\n"
150+
"formats. It can be just an integer number of seconds, a number plus units\n"
151+
"(ms/msec/us/usec/s/sec/m/min/h/hr), or an ISO 8601 period specification.\n\n"
152+
"Report bugs to users@clusterlabs.org";
159153

160154
GOptionEntry extra_prog_entries[] = {
161155
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &(args->quiet),
@@ -257,12 +251,6 @@ main(int argc, char **argv)
257251
case cmd_whois_dc:
258252
rc = pcmk__designated_controller(out, options.timeout);
259253
break;
260-
case cmd_shutdown:
261-
rc = pcmk__shutdown_controller(out, options.optarg);
262-
break;
263-
case cmd_elect_dc:
264-
rc = pcmk__start_election(out);
265-
break;
266254
case cmd_none:
267255
rc = pcmk_rc_error;
268256
break;

0 commit comments

Comments
 (0)