pcs icon indicating copy to clipboard operation
pcs copied to clipboard

Confusing error message in 'pcs constraint ticket add' when an unknown option is specified

Open F16shen opened this issue 2 years ago • 6 comments

A simple way to fix rhbz2022748 : https://bugzilla.redhat.com/show_bug.cgi?id=2022748 perhaps it's better to split 'options' into arguments and options?

F16shen avatar Sep 15 '22 08:09 F16shen

Can one of the admins verify this patch?

knet-ci-bot avatar Sep 15 '22 08:09 knet-ci-bot

test this please

tomjelinek avatar Sep 15 '22 08:09 tomjelinek

test this please

tomjelinek avatar Sep 19 '22 09:09 tomjelinek

Thank you for your patch. We are not going to accept it, however, for the following reasons:

pcs.lib.cib.constraint.constraint._validate_attrib_names is a generic function. Even if it is not used for other than ticket constraints now, it may be used for them later. As such, it should not have specific knowledge about one type of constraints which doesn't apply to other types.

By putting positional_arguments in pcs.lib.cib.constraint.constraint._validate_attrib_namesfunction, you put a knowledge about a client to the pcs library. This is a problem, as the library should be client-independent. What if someone writes a client where rsc, rsc-role and ticket are not positional arguments? How does the changed validation work with web UI?

The correct way to fix this issue is to modify error reports in the client, which in this case is pcs.cli.constraint_ticket.command.add.

tomjelinek avatar Sep 23 '22 13:09 tomjelinek

I move the _validate_attrib_names func to pcs.cli.constraint_ticket.command.add, is this what you mean?

F16shen avatar Sep 27 '22 10:09 F16shen

test this please

tomjelinek avatar Oct 03 '22 13:10 tomjelinek

Sorry for the delay. I add a testcase this time , but this commit cause pcs_test.tier0.cli.constraint_ticket.test_command.AddTest.test_put_resource_role_to_options_for_library to fail which confused me, wasn't it supposed to be cover by test_refuse_resource_role_in_options?

F16shen avatar Nov 29 '22 06:11 F16shen

Should I modify pcs_test/tier0/lib/cib/test_constraint_ticket.PrepareOptionsPlainTest.test_refuse_unknown_attributes as well?

F16shen avatar Nov 29 '22 06:11 F16shen

test this please

tomjelinek avatar Dec 01 '22 11:12 tomjelinek

Any news?

F16shen avatar Feb 03 '23 06:02 F16shen

I'm sorry it took us so long to get back to this PR.

It turned out that fixing this issue was not easy and straightforward at all due to suboptimal architecture in constraints creation. Once I figured out what needs to be done, it seemed too time consuming and complex to explain in comparison to writing the patch.

Nevertheless, thank you for your effort.

tomjelinek avatar Feb 09 '23 14:02 tomjelinek

test this please

tomjelinek avatar Feb 09 '23 14:02 tomjelinek