Bug 2168617 - Confusing error message in 'pcs constraint ticket add' when an unknown option is specified
Summary: Confusing error message in 'pcs constraint ticket add' when an unknown option...
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: pcs
Version: 9.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: 9.3
Assignee: Tomas Jelinek
QA Contact: cluster-qe
URL:
Whiteboard:
Depends On:
Blocks: 2022748
TreeView+ depends on / blocked
 
Reported: 2023-02-09 14:36 UTC by Tomas Jelinek
Modified: 2023-08-10 15:40 UTC (History)
8 users (show)

Fixed In Version: pcs-0.11.5-1.el9
Doc Type: No Doc Update
Doc Text:
This a minor self-documenting bugfix.
Clone Of: 2022748
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker CLUSTERQE-6634 0 None None None 2023-04-19 22:22:47 UTC
Red Hat Issue Tracker RHELPLAN-148174 0 None None None 2023-02-09 14:37:09 UTC

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


Note You need to log in before you can comment on or make changes to this bug.