Bug 1699978

Summary: crm_mon: fix command line parser for the -m/--fence-history option
Product: Red Hat Enterprise Linux 8 Reporter: Patrik Hagara <phagara>
Component: pacemakerAssignee: Chris Lumens <clumens>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: high    
Version: 8.0CC: aherr, bfrank, cfeist, cluster-maint, cluster-qe, jruemker, kgaillot, kwenning, mnovacek, msmazova, phagara, rhel8-maint, sbradley
Target Milestone: pre-dev-freeze   
Target Release: 8.2   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: pacemaker-2.0.3-1.el8 Doc Type: No Doc Update
Doc Text:
This is not significant enough for a release note
Story Points: ---
Clone Of: 1608369 Environment:
Last Closed: 2020-04-28 15:38:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1752538    
Bug Blocks:    

Description Patrik Hagara 2019-04-15 14:00:39 UTC
the help text for -m/--fence-history option of crm_mon states the following:

>  -m, --fence-history[=value]    Show fence history
>                                         0=off, 1=failures and pending (default without option),
>                                         2=add successes (default without value for option),
>                                         3=show full history without reduction to most recent of each flavor

however, neither "-m X" nor "-m=X" produce the expected output -- only "-mX" works as advertised.

affected version: pacemaker-2.0.1-4.el8

see bz#1608369, specifically comment https://bugzilla.redhat.com/show_bug.cgi?id=1608369#c8 for details.

Comment 2 Chris Lumens 2019-07-29 20:31:02 UTC
This should be fixed by https://github.com/ClusterLabs/pacemaker/pull/1847, which is just about ready to go in.

Comment 5 Markéta Smazová 2020-01-23 15:51:00 UTC
As previously stated in bz#1608369 and the description of this bug, the parser for the "crm_mon -m" option did not conform to the de-facto standard of allowing whitespace between short option and its argument (eg. "-m 0"). It only worked without any whitespace (eg. "-m0").

Using whitespace resulted in "non-option ARGV-elements: 0" warning and behaved as if only "crm_mon -m" (without value) was used.


After the fix:

>   [root@virt-137 ~]# rpm -q pacemaker
>   pacemaker-2.0.3-3.el8.x86_64

The usage of crm_mon -m is described in help:

>   [root@virt-137 ~]# crm_mon --help-display

>   Usage:
>     crm_mon [OPTION?]

>   Provides a summary of cluster's current state.
>   
>   [...]
>     -m, --fence-history=LEVEL         Show fence history:
>                                       0=off, 1=failures and pending (default without option),
>                                       2=add successes (default without value for option),
>                                       3=show full history without reduction to most recent of each flavor
>   [...]


Options "crm_mon -m 0" and "crm_mon -m0" and "crm_mon -m --fence-history=0" work as expected - they don't show fence history.

>   [root@virt-137 ~]# crm_mon -m 0

>   Cluster Summary:
>     * Stack: corosync
>     * Current DC:	virt-143 (version 2.0.3-3.el8-4b1f869f0f) - partition with quorum
>     * Last updated: Wed Jan 22 14:59:06 2020
>     * Last change:  Wed Jan 22 10:12:26 2020 by root via cibadmin on virt-137>   * 3 nodes configured
>     * 9 resource instances configured

>   Node List:
>     * Online: [ virt-137 virt-143 ]
>     * OFFLINE: [ virt-138 ]

>   Active Resources:
>     * fence-virt-137	(stonith:fence_xvm):     Started virt-137
>     * fence-virt-138	(stonith:fence_xvm):     Started virt-143
>     * fence-virt-143	(stonith:fence_xvm):     Started virt-143
>     * Clone Set: locking-clone [locking]:
>       * Started: [ virt-137 virt-143 ]


Options "crm_mon -m 1" and "crm_mon -m1" and "crm_mon -m --fence-history=1" correctly show only failed and pending fencing actions.
>   
>   [root@virt-137 ~]# crm_mon -m 1

>   Cluster Summary:
>     * Stack: corosync
>     * Current DC:	virt-143 (version 2.0.3-3.el8-4b1f869f0f) - partition with quorum
>     * Last updated: Wed Jan 22 15:19:36 2020
>     * Last change:  Wed Jan 22 15:18:41 2020 by root via cibadmin on virt-143
>     * 3 nodes configured
>     * 9 resource instances configured

>   Node List:
>     * Online: [ virt-137 virt-138 virt-143 ]

>   Active Resources:
>     * fence-virt-137	(stonith:fence_xvm):     Started virt-137
>     * fence-virt-138	(stonith:fence_xvm):     Started virt-143
>     * fence-virt-143	(stonith:fence_xvm):     Started virt-138
>     * Clone Set: locking-clone [locking]:
>       * Started: [ virt-137 virt-138 virt-143 ]

>   Failed Fencing Actions:
>     * reboot of virt-138. failed: delegate=, client=stonith_admin.2536, origin=virt-143, last-failed='2020-01-22 15:16:12 +01:00 '

>   Pending Fencing Actions:
>     * reboot of virt-138 pending: client=stonith_admin.2959, origin=virt-143

Options "crm_mon -m 2" and "crm_mon -m2" and "crm_mon -m --fence-history=2" add last successful pending action.

>   [root@virt-137 ~]# crm_mon -m 2

>   Cluster Summary:
>     * Stack: corosync
>     * Current DC:	virt-143 (version 2.0.3-3.el8-4b1f869f0f) - partition with quorum
>     * Last updated: Wed Jan 22 15:22:03 2020
>     * Last change:  Wed Jan 22 15:18:41 2020 by root via cibadmin on virt-143
>     * 3 nodes configured
>     * 9 resource instances configured

>   Node List:
>     * Online: [ virt-137 virt-138 virt-143 ]

>   Active Resources:
>     * fence-virt-137	(stonith:fence_xvm):     Started virt-137
>     * fence-virt-138	(stonith:fence_xvm):     Started virt-143
>     * fence-virt-143	(stonith:fence_xvm):     Started virt-138
>     * Clone Set: locking-clone [locking]:
>       * Started: [ virt-137 virt-138 virt-143 ]

>   Failed Fencing Actions:
>     * reboot of virt-138. failed: delegate=, client=stonith_admin.2536, origin=virt-143, last-failed='2020-01-22 15:16:12 +01:00 '

>   Fencing History:
>     * reboot of virt-138 pending: client=stonith_admin.3290, origin=virt-143
>     * reboot of virt-138 successful: delegate=virt-143, client=stonith_admin.3290, origin=virt-143, last-successful='2020-01-22 15:22:17 +01:00'


Options "crm_mon -m 3" and "crm_mon -m3" and "crm_mon -m --fence-history=3" show failed and pending actions and all history of sucessful fencing actions.

>   [root@virt-137 ~]# crm_mon -m 3

>   Cluster Summary:
>     * Stack: corosync
>     * Current DC:	virt-143 (version 2.0.3-3.el8-4b1f869f0f) - partition with quorum
>     * Last updated: Wed Jan 22 15:31:52 2020
>     * Last change:  Wed Jan 22 15:18:41 2020 by root via cibadmin on virt-143
>     * 3 nodes configured
>     * 9 resource instances configured

>   Node List:
>     * Online: [ virt-137 virt-138 virt-143 ]

>   Active Resources:
>     * fence-virt-137	(stonith:fence_xvm):     Started virt-137
>     * fence-virt-138	(stonith:fence_xvm):     Started virt-143
>     * fence-virt-143	(stonith:fence_xvm):     Started virt-138
>     * Clone Set: locking-clone [locking]:
>       * Started: [ virt-137 virt-138 virt-143 ]

>   Failed Fencing Actions:
>     * reboot of virt-138. failed: delegate=, client=stonith_admin.2536, origin=virt-143, completed='2020-01-22 15:16:12 +01:00 '

>   Fencing History:
>     * reboot of virt-138 pending: client=stonith_admin.4984, origin=virt-143
>     * reboot of virt-138 successful: delegate=virt-143, client=stonith_admin.3290, origin=virt-143, completed='2020-01-22 15:22:17 +01:00'
>     * reboot of virt-138 successful: delegate=virt-143, client=stonith_admin.2959, origin=virt-143, completed='2020-01-22 15:19:48 +01:00'
>     * reboot of virt-138 successful: delegate=virt-137, client=stonith_admin.32651, origin=virt-143, completed='2020-01-22 14:59:03 +01:00'


Using "=" as option-value separator is not supported for short options and results in error:

>   [root@virt-137 ~]# crm_mon -m=0
>   crm_mon: Fence history must be 0-3
>   Usage:
>     crm_mon [OPTION…]
>   [...]

Long options do support using "=", eg. "crm_mon -m --fence-history=0".

Comment 7 errata-xmlrpc 2020-04-28 15:38:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:1609