File bsc#1217259-0002-Fix-tools-restore-crmadmin-default-timeout-to-30-sec.patch of Package pacemaker.38493

From 6506a0bff33e36e538e234c7fe0c3cde47bd9838 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 16 Oct 2024 11:45:26 -0500
Subject: [PATCH] Fix: tools: restore crmadmin default timeout to 30 seconds

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.
---
 tools/crmadmin.8.inc |  3 +++
 tools/crmadmin.c     | 25 ++++++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

Index: pacemaker-2.1.5+20221208.a3f44794f/tools/crmadmin.8.inc
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/tools/crmadmin.8.inc
+++ pacemaker-2.1.5+20221208.a3f44794f/tools/crmadmin.8.inc
@@ -3,3 +3,6 @@ crmadmin [options] [node]
 
 /the Pacemaker controller/
 .SH OPTIONS
+
+/query information/
+.SH NOTES
Index: pacemaker-2.1.5+20221208.a3f44794f/tools/crmadmin.c
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/tools/crmadmin.c
+++ pacemaker-2.1.5+20221208.a3f44794f/tools/crmadmin.c
@@ -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
@@ -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'"
@@ -135,17 +137,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 users@clusterlabs.org" 
+
+
 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 users@clusterlabs.org";
-
     GOptionEntry extra_prog_entries[] = {
         { "quiet", 'q', 0, G_OPTION_ARG_NONE, &(args->quiet),
           "Display only the essential query information",
@@ -155,7 +158,7 @@ build_arg_context(pcmk__common_args_t *a
     };
 
     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.
openSUSE Build Service is sponsored by