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'
Upstream patch based on a pull request from a community: https://github.com/ClusterLabs/pcs/commit/4da2e7148d22ce87736a2c036d1eceff5a9d830f 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
DevTestResults: [root@r08-09-a ~]# rpm -q pcs pcs-0.10.16-1.el8.x86_64 [root@r08-09-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
## BEFORE [root@virt-544 ~]# rpm -q pcs pcs-0.10.15-4.el8_8.1.x86_64 [root@virt-544 ~]# 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 master, slave, started or stopped. [root@virt-544 ~]# pcs resource create d1 ocf:heartbeat:Dummy [root@virt-544 ~]# echo $? 0 [root@virt-544 ~]# 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-539 ~]# rpm -q pcs pcs-0.10.16-1.el8.x86_64 [root@virt-539 ~]# 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 master, slave, started or stopped. [root@virt-539 ~]# pcs resource create d1 ocf:heartbeat:Dummy [root@virt-539 ~]# echo $? 0 A.) Checking the error message in case of entering an invalid option [root@virt-539 ~]# 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-539 ~]# echo $? 1 > OK. B.) Checking the error message in case of entering valid option with invalid value [root@virt-539 ~]# 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-539 ~]# echo $? 1 > OK. C.) Checking the error message in case of entering valid option with invalid option [root@virt-539 ~]# 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-539 ~]# echo $? 1 > OK. D.) Checking results in case of entering valid option [root@virt-539 ~]# pcs constraint ticket add ticket1 d1 loss-policy=stop [root@virt-539 ~]# echo $? 0 [root@virt-539 ~]# pcs constraint ticket Ticket Constraints: d1 loss-policy=stop ticket=ticket1 > OK. > Marking as VERIFIED for pcs-0.10.16-1.el8.x86_64