Adding ability to scale for Redis Cache, adding tests#2821
Adding ability to scale for Redis Cache, adding tests#2821tjprescott merged 7 commits intoAzure:masterfrom
Conversation
|
@alfantp, It will cover your contributions to all Microsoft-managed open source projects. |
Codecov Report
@@ Coverage Diff @@
## master #2821 +/- ##
==========================================
+ Coverage 62.89% 63.17% +0.27%
==========================================
Files 480 466 -14
Lines 26012 26139 +127
Branches 3946 3997 +51
==========================================
+ Hits 16361 16514 +153
+ Misses 8627 8544 -83
- Partials 1024 1081 +57
Continue to review full report at Codecov.
|
tjprescott
left a comment
There was a problem hiding this comment.
The addition of the SKU parameters is fine, but then "redis_configuration" should be removed and this should be a "generic update" command (with --set, --add, --remove). Also, it seems the command should be named "redis update" instead of "update-settings".
| def cli_redis_update_settings(client, resource_group_name, name, redis_configuration): | ||
| def cli_redis_update_settings(client, resource_group_name, name, redis_configuration=None, # pylint:disable=too-many-arguments | ||
| sku_name=None, sku_family=None, sku_capacity=None): | ||
| if sku_name != None or sku_family != None or sku_capacity != None: |
There was a problem hiding this comment.
Recommendation:
sku_group = [sku_name, sku_family, sku_capacity]
if any(sku_group) and not all(sku_group):
raise CLIError('incorrect usage: --sku-name NAME --sku-family FAMILY --sku-capactity CAPACITY')The "usage string" style error is favored.
There was a problem hiding this comment.
Thanks for the recommendation. Will update it. About renaming the command name, wouldnt changing the name break existing customers who use this for automations? Or since the product is in its early stages it's okay to do that? I'll be very willing to change the command if you can confirm its okay
There was a problem hiding this comment.
It would. Also, looking into it, apparently the "redis-configuration" parameter only lets you change a very specific subset of things that aren't clearly enumerated.
In that case, my recommendation is:
- create a new command called "redis update" that uses the "cli_generic_update" pattern that other resource types use.
- Move the SKU related parameters as the convenience layer on that command, and leave "redis update-settings" as is.
- In the future, we can deprecate "update-settings" (as the generic update would accomplish everything it does and more).
| existing.redis_configuration.update(redis_configuration) | ||
|
|
||
| if sku_name != None and sku_family != None and sku_capacity != None: | ||
| existing.sku = Sku(sku_name, sku_family, sku_capacity) |
There was a problem hiding this comment.
Why are we exposing a "configuration" object AND convenience parameters? This looks like it should be a generic update command and "redis_configuration" should be removed.
There was a problem hiding this comment.
There are two ways to update a cache. One, you can update the Sku/VMSize to scale. Second, you can update the settings/properties within cache like say max memory threshold or backup interval etc. So IMO, it's fine to have both. Also, this is how the command is in powershell.
…Adding 'getting deprecated' message for update-settings command
tjprescott
left a comment
There was a problem hiding this comment.
Looks much better. A few suggestions. Main ask is to replace the hard-coded enum with more flexible parsing and let the service handle that validation. Feel free to reach out to me with questions.
| =============== | ||
|
|
||
| * Adding update command which also adds the ability to scale for redis cache | ||
| * Adding 'getting deprecated' message for update-settings command |
There was a problem hiding this comment.
Rec: Deprecates the 'update-settings' command.
| type: command | ||
| short-summary: Update the settings of a redis cache. | ||
| long-summary: | | ||
| WARNING: This command is being deprecated. Please use 'update' command |
There was a problem hiding this comment.
Recommend you add (DEPRECATED) to the short summary so it shows up in az redis -h. I like that the long summary directs the user to the right command.
| dictval = shell_safe_json_parse(value) | ||
| self.update(dictval) | ||
|
|
||
| class VmSize(Enum): # pylint: disable=too-few-public-methods |
There was a problem hiding this comment.
This is definitely one way of doing this but then it has the problem that you have to manually add things to this enum if the service supports something new.
I would recommend something like this:
family = size[0]
capacity = int(size[1:])And then in the help for the param, you give examples of the format. "C1, P2, etc." In this way, if the service starts to support additional combinations, then the CLI will automatically support them instead of artificially restricting them.
| register_cli_argument('redis', 'vm_size', **enum_choice_list(VmSize)) | ||
| register_cli_argument('redis', 'enable_non_ssl_port', action='store_true') | ||
| register_cli_argument('redis', 'shard_count', type=int) | ||
| register_cli_argument('redis', 'subnet_id') # TODO: Create generic id completer similar to name |
There was a problem hiding this comment.
Please create an issue for this follow-up work.
| :param sku_name: What type of redis cache to deploy. Valid values: (Basic, Standard, Premium). | ||
| :param sku_family: Which family to use. Valid values: (C, P). | ||
| :param sku_capacity: What size of redis cache to deploy. Valid values for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4) | ||
| :param sku: What type of redis cache to deploy. Valid values: (Basic, Standard, Premium). |
There was a problem hiding this comment.
If you are using the **enum_choice_list, it will automatically list (and validate) the options, so you don't need this. If you run this command with -h you'll see the list essentially repeated twice.
| :param sku_family: Which family to use. Valid values: (C, P). | ||
| :param sku_capacity: What size of redis cache to deploy. Valid values for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4) | ||
| :param sku: What type of redis cache to deploy. Valid values: (Basic, Standard, Premium). | ||
| :param vm_size: What size of redis cache to deploy. Valid values for C family (C0, C1, C2, C3, C4, C5, C6), for P family (P1, P2, P3, P4) |
There was a problem hiding this comment.
And here, if you do like I suggest and parse the size, you will still need this so this is good.
| params = RedisCreateOrUpdateParameters( | ||
| location, | ||
| Sku(sku_name, sku_family, sku_capacity), | ||
| Sku(sku, vm_size[0], vm_size[1]), |
There was a problem hiding this comment.
I would recommend vm_size[1:] in case you ever support double digit capacity values.
troydai
left a comment
There was a problem hiding this comment.
Please run check_style --ci before push.
| P1 = 'P1' | ||
| P2 = 'P2' | ||
| P3 = 'P3' | ||
| P4 = 'P4' |
There was a problem hiding this comment.
Are these sizes defined in the SDK? Do we have to hard code the options in CLI? Could this list be impacted by other factors?
| register_cli_argument('redis', 'vm_size', **enum_choice_list(VmSize)) | ||
| register_cli_argument('redis', 'enable_non_ssl_port', action='store_true') | ||
| register_cli_argument('redis', 'shard_count', type=int) | ||
| register_cli_argument('redis', 'subnet_id') # TODO: Create generic id completer similar to name |
There was a problem hiding this comment.
I'm sure pylint will reject this line. Two space between same line comments.
There was a problem hiding this comment.
Actually, pylint doesn't care. It's PEP8 that hates this... ... ... for some reason.
| cli_command(__name__, 'redis show', 'azure.mgmt.redis.operations.redis_operations#RedisOperations.get', cf_redis) | ||
| cli_command(__name__, 'redis update-settings', 'azure.cli.command_modules.redis.custom#cli_redis_update_settings', cf_redis) | ||
|
|
||
| cli_generic_update_command(__name__, 'redis update', 'azure.mgmt.redis.operations.redis_operations#RedisOperations.get', 'azure.mgmt.redis.operations.redis_operations#RedisOperations.create_or_update', cf_redis, custom_function_op='azure.cli.command_modules.redis.custom#cli_redis_update') |
| args = mock_echo_args('redis create', | ||
| '--tenant-settings {\"hello\":1} -g wombat -n asldkj --sku-family c -l westus --sku-capacity 1 --sku-name basic') # pylint: disable=line-too-long | ||
| '--tenant-settings {\"hello\":1} -g wombat -n asldkj -l westus --sku basic --vm-size C1 ') # pylint: disable=line-too-long | ||
| subset = set(dict( |
There was a problem hiding this comment.
this is short enough now to be put on the same line.
|
@troydai are you good with the changes? If so I'd like to merge this for the release. |
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Command Guidelines
(see Authoring Command Modules)