Comment 0 for bug 1555764

Revision history for this message
Piyush (pirsriva) wrote :

The validate_args() function in rally.cli.cliutils (https://github.com/openstack/rally/blob/master/rally/cli/cliutils.py#L69) is meant to cross check whether all the required args ( which DO NOT HAVE a default value associated ) are present or not and then invoke the function.

For e.g. rally task start will refer to https://github.com/openstack/rally/blob/master/rally/cli/commands/task.py#L203. In this there is one required argument - task. Thus user HAS TO ALWAYS pass the value for "task" argument while invoking "rally task start"

The current logic for validate_args() is based on count of required_args and NOT the name of the required_args.
This logic may fail if there is more than 1 required args for any function.

Consider the following modified version of "rally task start" parsing using the same code logic from rally.cli.cliutils - http://paste.openstack.org/show/490047/

Here i have intentionally made BOTH task and deployment as mandatory argument. With the current validation_args() function, if i do-
rally task start T1 --task T1
The call should IDEALLY fail since "deployment" argument has not been passed to the function ( 1st positional argument represents"task" as well ) BUT that does not happen. Based on the count logic, the function mistakenly assumes that the 2 required args for function have been passed in the command.
(This can be verified by running the code in above paste.openstack link )

NOTE- This issue does not occur so far since all the CLI command functions in various classes ( task, deployment, show, verify, .. ) had only 1 REQUIRED ARGUMENT always. Hence the count logic works currently.

I did not find any documentation of hard-constraint that all rally command functions need to have only 1 required argument. If we introduce / modify any Rally command function in future that needs more than 1 required arguments then the bug condition will appear.