Bug 2168617

Summary: Confusing error message in 'pcs constraint ticket add' when an unknown option is specified
Product: Red Hat Enterprise Linux 9 Reporter: Tomas Jelinek <tojeline>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: low    
Version: 9.0CC: cluster-maint, idevat, mlisik, mmazoure, mpospisi, nhostako, omular, tojeline
Target Milestone: rcKeywords: Triaged
Target Release: 9.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.11.5-1.el9 Doc Type: No Doc Update
Doc Text:
This a minor self-documenting bugfix.
Story Points: ---
Clone Of: 2022748 Environment:
Last Closed: 2023-11-07 08:23:10 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:    
Bug Blocks: 2022748    

Description Tomas Jelinek 2023-02-09 14:36:47 UTC
+++ This bug was initially created as a clone of Bug #2022748 +++

Description of problem:
When an unknown option name is specified, pcs reports that (which is ok) and lists allowed option names. The list of allowed options contains items which are not meant to be specified as options: rsc (for resource), rsc-role (for resource role) and ticket. These three options are supposed to be specified as positional arguments of the command as is shown in usage:
ticket add <ticket> [<role>] <resource id> [<options>] [id=<constraint-id>]


Version-Release number of selected component (if applicable):
pcs-0.10.11-1.el8


How reproducible:
always, easily


Steps to Reproduce:
1. pcs constraint ticket add ticket1 resource1 unknown=option


Actual results:
Error: invalid option 'x', allowed options are: 'id', 'loss-policy', 'rsc', 'rsc-role', 'ticket'


Expected results:
Error: invalid option 'x', allowed options are: 'id', 'loss-policy'

Comment 1 Tomas Jelinek 2023-02-10 09:08:32 UTC
Upstream patch based on a pull request from a community:
https://github.com/ClusterLabs/pcs/commit/c2cae53d4bac9b6c4c091ba56b7fc74968af3438


Test:
# pcs constraint ticket add ticket d1 unknown=option
Error: invalid option 'unknown', allowed options are: 'id', 'loss-policy'
Error: Errors have occurred, therefore pcs is unable to continue

Comment 3 Michal Pospisil 2023-05-26 09:28:14 UTC
DevTestResults:

[root@r09-03-a ~]# rpm -q pcs
pcs-0.11.5-1.el9.x86_64

[root@r09-03-a ~]# pcs constraint ticket add ticket r1 unknown=option  
Error: invalid option 'unknown', allowed options are: 'id', 'loss-policy'
Error: Errors have occurred, therefore pcs is unable to continue

Comment 7 svalasti 2023-06-13 13:39:36 UTC
## BEFORE

[root@virt-022 ~]# rpm -q pcs
pcs-0.11.4-7.el9_2.x86_64

[root@virt-022 ~]# pcs constraint ticket add -h

Usage: pcs constraint [constraints]...
    ticket add <ticket> [<role>] <resource id> [<options>]
               [id=<constraint-id>]
        Create a ticket constraint for <resource id>.
        Available option is loss-policy=fence/stop/freeze/demote.
        A role can be Promoted, Unpromoted, Started or Stopped.

[root@virt-022 ~]# pcs resource create d1 ocf:heartbeat:Dummy

[root@virt-022 ~]# echo $?
0

[root@virt-022 ~]# pcs constraint ticket add ticket1 d1 invalid-option=false
Error: invalid option 'invalid-option', allowed options are: 'id', 'loss-policy', 'rsc', 'rsc-role', 'ticket'

> When an unknown option is specified, then the list of allowed options contains positional arguments such as resource, resource-role and ticket.


## AFTER

[root@virt-525 ~]# rpm -q pcs
pcs-0.11.5-2.el9.x86_64

[root@virt-525 ~]# pcs constraint ticket add -h

Usage: pcs constraint [constraints]...
    ticket add <ticket> [<role>] <resource id> [<options>]
               [id=<constraint-id>]
        Create a ticket constraint for <resource id>.
        Available option is loss-policy=fence/stop/freeze/demote.
        A role can be Promoted, Unpromoted, Started or Stopped.

[root@virt-525 ~]# pcs resource create d1 ocf:heartbeat:Dummy

[root@virt-525 ~]# echo $?
0


A.) Checking the error message in case of entering an invalid option

[root@virt-525 ~]# pcs constraint ticket add ticket1 d1 invalid-option=false
Error: invalid option 'invalid-option', allowed options are: 'id', 'loss-policy'
Error: Errors have occurred, therefore pcs is unable to continue

[root@virt-525 ~]# echo $?
1

> OK.


B.) Checking the error message in case of entering valid option with invalid value

[root@virt-525 ~]# pcs constraint ticket add ticket1 d1 loss-policy=9
Error: '9' is not a valid loss-policy value, use 'demote', 'fence', 'freeze', 'stop'
Error: Errors have occurred, therefore pcs is unable to continue

[root@virt-525 ~]# echo $?
1

> OK.


C.) Checking the error message in case of entering valid option with invalid option

[root@virt-525 ~]# pcs constraint ticket add ticket1 d1 loss-policy=stop invalid-option=false
Error: invalid option 'invalid-option', allowed options are: 'id', 'loss-policy'
Error: Errors have occurred, therefore pcs is unable to continue

[root@virt-525 ~]# echo $?
1

> OK.


D.) Checking results in case of entering valid option

[root@virt-525 ~]# pcs constraint ticket add ticket1 d1 loss-policy=stop

[root@virt-525 ~]# echo $?
0

[root@virt-525 ~]# pcs constraint ticket
Ticket Constraints:
  resource 'd1' depends on ticket 'ticket1'
    loss-policy=stop

> OK.

> Marking as VERIFIED for pcs-0.11.5-2.el9.x86_64

Comment 11 errata-xmlrpc 2023-11-07 08:23:10 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 (Low: pcs security, bug fix, and enhancement update), 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/RHSA-2023:6316