Conversation
|
@yugangw-msft, thanks for your PR! By analyzing the history of the files in this pull request, we identified @derekbekoe, @johanste, @tjprescott, @brendandburns and @zooba to be potential reviewers. |
| @@ -240,10 +241,10 @@ def register_extra_cli_argument(command, dest, **kwargs): | |||
| _cli_extra_argument_registry[command][dest] = CliCommandArgument(dest, **kwargs) | |||
|
|
|||
| def cli_command(module_name, name, operation, | |||
There was a problem hiding this comment.
Should we add a **kwargs argument if we expect to add more of these "pass-through" parameters?
There was a problem hiding this comment.
Agreed. After the main logic gets reviewed, I will consolidate
There was a problem hiding this comment.
Just so long as the public facing cli_command(...) call does not use kwargs (coughresource_idcough)
tjprescott
left a comment
There was a problem hiding this comment.
Mostly just some comments from what I saw in the help text. I'll do a more detailed review when you are ready to merge it.
| cmd.add_argument('deleted', '--deleted', action='store_true', arg_group=group_name, | ||
| help='wait till deleted') | ||
| cmd.add_argument('created', '--created', action='store_true', arg_group=group_name, | ||
| help="wait till created with 'provisitioningState' at 'Succeeded'") |
There was a problem hiding this comment.
typo: provisioningState instead of provisitioningState. Also line 410.
| help="wait till updated with provisitioningState at 'Succeeded'") | ||
| cmd.add_argument('exists', '--exists', action='store_true', arg_group=group_name, | ||
| help="wait till the resource exists") | ||
| cmd.add_argument('property', '--property', arg_group=group_name, |
There was a problem hiding this comment.
Recommend '--custom' and a message like "Wait until the condition satisfies a custom JMESPath query."
|
|
||
| cmd = CliCommand(name, handler, table_transformer=table_transformer, | ||
| arguments_loader=arguments_loader) | ||
| group_name = 'Wait' |
|
What would example usage of this look like with a template deployment for example? I guess I'd name the deployment and then I could later wait on the deployment? Something like that roughly? |
|
@colemickens that's right. Each resource (deployment being the resource in this case) will expose a wait command which lets you poll on some property that is exposed through that resource's GET method. You would probably have to add the |
|
@colemickens, that is correct. |
|
@colemickens, you can also use |
|
In this case In this case, and normal ARM teminology... the deployment is "created" as soon as the 201/202 is sent back... and transitions from InProgess to Succeeded. It's a tiny bit confusing, but I guess for other resources the meaning is pretty clear. |
There was a problem hiding this comment.
So if 'raw' not in kwargs, we essentially ignore the --no-wait parameter?
Will this be a common thing, if so, consider adding logger.warning message like 'Ignoring no wait because ...'.
There was a problem hiding this comment.
The no-wait is a parameter alias on raw. This if condition makes sure the command returns nothing on no-wait, since we don't have yet the final result to return to users.
There was a problem hiding this comment.
Or perhaps it should be an error instead of a warning. If you register no-wait on a command that doesn't support raw, then I would argue it would be better to have that fail positively than just vaguely "not work".
There was a problem hiding this comment.
I will raise exception in _introspection.py where we do parameter excursion and alias
There was a problem hiding this comment.
I think to match the parameter names:
create -> created
delete -> deleted
exits -> exists
If 'property' a valid flag?
There was a problem hiding this comment.
thanks, I forgot to rename it to custom
There was a problem hiding this comment.
-
Looks like 'property' was renamed 'custom' so this just needs to be updated. Also, 'exists' is misspelled 'exits'.
-
We might consider having a default here instead of raising an error when nothing is specified.
-
Also, recommend this form for the error: "incorrect usage: --created | --updated | --deleted | --exists | --custom JMESPATH"
There was a problem hiding this comment.
Do the wait commands return objects?
Looks like it won't return anything?
There was a problem hiding this comment.
Correct. When the wait is successful you are returned to the command prompt. GET is an implementation detail behind the wait, but there's no need to return the object from the final GET.
There was a problem hiding this comment.
More descriptive message like 'Wait operation timed-out after X seconds'
There was a problem hiding this comment.
Would be good if there was a validator on this parameter to check that the string is a valid JMESPath query so the command will fail even before any API calls are made.
There was a problem hiding this comment.
I think it does that at line 423 essentially. It compiles the JMESPath, which should raise an error if it is invalid.
There was a problem hiding this comment.
Yep. Invalid JmesPath will be raised
I felt about the same. Let me think about whether I can improve the naming. For lots of "create" commands, |
|
@colemickens But I don't think customers will care so much what the ARM team considers created, so we want to go with what will make sense to them. |
82b156e to
acaa1fa
Compare
acaa1fa to
edf62f4
Compare
tjprescott
left a comment
There was a problem hiding this comment.
Overall, I'm really excited to get this change in. Changes requested are mostly typos, but also some other questions.
| @@ -240,10 +241,10 @@ def register_extra_cli_argument(command, dest, **kwargs): | |||
| _cli_extra_argument_registry[command][dest] = CliCommandArgument(dest, **kwargs) | |||
|
|
|||
| def cli_command(module_name, name, operation, | |||
There was a problem hiding this comment.
Just so long as the public facing cli_command(...) call does not use kwargs (coughresource_idcough)
There was a problem hiding this comment.
Or perhaps it should be an error instead of a warning. If you register no-wait on a command that doesn't support raw, then I would argue it would be better to have that fail positively than just vaguely "not work".
There was a problem hiding this comment.
This should be positively resolved during the command registration, so I would argue you simply get the raw property here.
There was a problem hiding this comment.
My concern is it is possible (though very unlikely) an custom method might contain raw parameter for other purpose.
There was a problem hiding this comment.
Or we can consider to letting the command registration flow to expose one more argument say no_wait_param, and default to raw. This way we have the decoupling and be explicit, of course the registration logic (public facing API) looks a bit more complex.
There was a problem hiding this comment.
I made the change. Please take a look. It is easy to rollback if we feel the complexity not worth it
There was a problem hiding this comment.
Since wait always returns nothing, table_transformer will never apply.
There was a problem hiding this comment.
Would this be a TypeError? Also, recommend the message contain type(getter_op) instead of just getter_op. If someone passed 10 it would say "Got '10'" instead of "Got 'int'".
There was a problem hiding this comment.
Okay, updated. Note, this is the code pattern which exists at several places. I just reused it.
There was a problem hiding this comment.
-
Looks like 'property' was renamed 'custom' so this just needs to be updated. Also, 'exists' is misspelled 'exits'.
-
We might consider having a default here instead of raising an error when nothing is specified.
-
Also, recommend this form for the error: "incorrect usage: --created | --updated | --deleted | --exists | --custom JMESPATH"
There was a problem hiding this comment.
Correct. When the wait is successful you are returned to the command prompt. GET is an implementation detail behind the wait, but there's no need to return the object from the final GET.
There was a problem hiding this comment.
I think it does that at line 423 essentially. It compiles the JMESPath, which should raise an error if it is invalid.
|
@tjprescott, please take another look. |
| if not expose_raw_as_no_wait: | ||
| excluded_params.append('raw') | ||
| elif not 'raw' in args: | ||
| raise ValueError("There is no 'raw' argument exposed for no-wait") |
There was a problem hiding this comment.
This would confuse me if I were not familiar with the implementation of no-wait. I would suggest something like "Unable to enable no-wait option. Operation '{}' does not have a 'raw' parameter.".format(operation.name)
In other words, make it clear that the method must have the 'raw' capability in order to expose no-wait through this argument.
| def cli_command(module_name, name, operation, | ||
| client_factory=None, transform=None, table_transformer=None, expose_no_wait=False): | ||
| client_factory=None, transform=None, table_transformer=None, | ||
| expose_no_wait=False, no_wait_param=None): |
There was a problem hiding this comment.
Having both expose_no_wait and no_wait_param seems redundant. If no_wait_param is None then you implicitly haven't enabled it. If it is anything else, then you have enabled it. However, I do like this way, of simply specifying the parameter name as it accomplishes the same thing with a little more flexibility.
I would add a check here to verify that the param no_wait_param refers to is a boolean type and throw if it is not. Otherwise someone will try and use a string field or something and things will work in mysterious ways.
tjprescott
left a comment
There was a problem hiding this comment.
I like the decoupling. Adds a little for flexibility for not much more complexity. Added a couple more comments for some minor changes.
51c0786 to
63dd5ec
Compare
63dd5ec to
e6bf2c4
Compare
Submit it to leverage CI to catch regressions. Still finalizing the change, but feel free to put in comments.
Fix #1071, Fix #1169
This change enable author to expose
--no-waitfrom long running command, and also exposewaitcommands to wait on any conditions based onreadapi.