From 68d1e4242f165917bc2c787d9df0fe41251e05e6 Mon Sep 17 00:00:00 2001 From: Lars Ellenberg Date: Wed, 12 Jan 2022 13:50:35 +0100 Subject: [PATCH] crm-fence-peer: fix timeout with Pacemaker 2.0.5: milli seconds vs seconds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addendum to 8a28be74bc6efa93931c957e54c01abb18b984fe Commit message of the above cited here: > crmadmin timeout was in milli seconds for <= 2.0.x, > but became a TIMESPEC with default seconds in >= 2.1. > > Up to 2.0.4, atoi() was used, which effectively ignores "trailing garbage", > so we could get away with always appending "ms". > But with 2.0.5, it became g_option_context_parse G_OPTION_ARG_INT, which > "Cannot parse integer value “200ms” for --timeout" :-| > > So grep the help message for "timeout.*milliseconds", > and if not present, append an explicit "ms" unit. And this is where I got it wrong :-( somewhere later they re-organised the help text so now I would need to parse --help-all. Instead try to actually call "crmadmin -t 100ms --version". If that works, it apparently understands (or ignores) the "ms" unit. --- scripts/crm-fence-peer.9.sh | 14 +++++++++++--- scripts/crm-fence-peer.sh | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/scripts/crm-fence-peer.9.sh b/scripts/crm-fence-peer.9.sh index c943bf9f..fc8d2bc3 100755 --- a/scripts/crm-fence-peer.9.sh +++ b/scripts/crm-fence-peer.9.sh @@ -400,10 +400,18 @@ setup_crm_timeout_unit_ms() # garbage", so we could get away with always appending "ms", but with # 2.0.5, it became g_option_context_parse G_OPTION_ARG_INT, which # "Cannot parse integer value “200ms” for --timeout" :-| - if crmadmin --help 2>&1 | grep -q -e "--timeout=.*in milliseconds"; then - crm_timeout_unit_ms="" - else + # Can not parse the help text reliably, because they changed content + # and organisation of the help text between 2.0.4 and 2.0.5. + # Just try using ms unit, and see if it fails. + if crmadmin -t 100ms --version &> /dev/null; then + # this is either a recent version that actually understands ms + # as part of the TIMESPEC, or a version that still uses atoi(). crm_timeout_unit_ms="ms" + else + # this one likely failed with + # crmadmin: Cannot parse integer value “100ms” for -t + # (>= 2.0.5, < 2.1) + crm_timeout_unit_ms="" fi } diff --git a/scripts/crm-fence-peer.sh b/scripts/crm-fence-peer.sh index 96786734..b0e4e0f1 100755 --- a/scripts/crm-fence-peer.sh +++ b/scripts/crm-fence-peer.sh @@ -252,10 +252,18 @@ setup_crm_timeout_unit_ms() # garbage", so we could get away with always appending "ms", but with # 2.0.5, it became g_option_context_parse G_OPTION_ARG_INT, which # "Cannot parse integer value “200ms” for --timeout" :-| - if crmadmin --help 2>&1 | grep -q -e "--timeout=.*in milliseconds"; then - crm_timeout_unit_ms="" - else + # Can not parse the help text reliably, because they changed content + # and organisation of the help text between 2.0.4 and 2.0.5. + # Just try using ms unit, and see if it fails. + if crmadmin -t 100ms --version &> /dev/null; then + # this is either a recent version that actually understands ms + # as part of the TIMESPEC, or a version that still uses atoi(). crm_timeout_unit_ms="ms" + else + # this one likely failed with + # crmadmin: Cannot parse integer value “100ms” for -t + # (>= 2.0.5, < 2.1) + crm_timeout_unit_ms="" fi } -- 2.40.0