From 98e5d8a7d98f1952d33cebb0f646823a8b912692 Mon Sep 17 00:00:00 2001 From: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com> Date: Wed, 6 Jul 2022 11:26:03 +0530 Subject: [PATCH 1/5] {AzContainerApp} fixes Azure/azure-cli-extensions#5067 az containerapp update -n ContainerAppName -g ResourceGroup --min-replicas 0 --max-replicas 0 finishes without throwing any error, however scaling configuration is not updated as max replicas cannot be zero. This PR should include a fix to validate the --max-replicas field while the value is sent as Zero and raise CLIError --- src/containerapp/azext_containerapp/custom.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index 58f5f65dd49..d1b368f1cef 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -504,6 +504,11 @@ def update_containerapp_logic(cmd, from_revision=None): _validate_subscription_registered(cmd, CONTAINER_APPS_RP) + # Validate that max_replicas is set to 0-30""" + if max_replicas is not None: + if max_replicas < 1 or max_replicas > 30: + raise CLIError('--max_replicas must be in the range [1,30]') + if yaml: if image or min_replicas or max_replicas or\ set_env_vars or remove_env_vars or replace_env_vars or remove_all_env_vars or cpu or memory or\ From 8f0ebeb80dfc4bac6c09bec6a10f89249cc0b6e7 Mon Sep 17 00:00:00 2001 From: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com> Date: Wed, 6 Jul 2022 11:37:41 +0530 Subject: [PATCH 2/5] Update custom.py --- src/containerapp/azext_containerapp/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index d1b368f1cef..a3cdf7fb775 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -504,7 +504,7 @@ def update_containerapp_logic(cmd, from_revision=None): _validate_subscription_registered(cmd, CONTAINER_APPS_RP) - # Validate that max_replicas is set to 0-30""" + # Validate that max_replicas is set to 0-30 if max_replicas is not None: if max_replicas < 1 or max_replicas > 30: raise CLIError('--max_replicas must be in the range [1,30]') From 6411b93c2e5987543dd7ba92bbe1e42616d910e8 Mon Sep 17 00:00:00 2001 From: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com> Date: Mon, 11 Jul 2022 12:24:22 +0530 Subject: [PATCH 3/5] {AzContainerApp} fixes Azure/azure-cli-extensions#5067 used the specific error type ArgumentUsageError instead of CLIError az containerapp update -n ContainerAppName -g ResourceGroup --min-replicas 0 --max-replicas 0 finishes without throwing any error, however scaling configuration is not updated as max replicas cannot be zero. This PR should include a fix to validate the --max-replicas field while the value is sent as Zero and raise CLIError fixes #5067 --- src/containerapp/azext_containerapp/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index a3cdf7fb775..cbd82654c59 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -507,7 +507,7 @@ def update_containerapp_logic(cmd, # Validate that max_replicas is set to 0-30 if max_replicas is not None: if max_replicas < 1 or max_replicas > 30: - raise CLIError('--max_replicas must be in the range [1,30]') + raise ArgumentUsageError('--max_replicas must be in the range [1,30]') if yaml: if image or min_replicas or max_replicas or\ From 46aa677d34ed1265ad4f39d5fb628f6e16f2cbd9 Mon Sep 17 00:00:00 2001 From: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com> Date: Mon, 11 Jul 2022 12:26:22 +0530 Subject: [PATCH 4/5] Update src/containerapp/azext_containerapp/custom.py updated Co-authored-by: Xing Zhou --- src/containerapp/azext_containerapp/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index cbd82654c59..d5b7a17042d 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -507,7 +507,7 @@ def update_containerapp_logic(cmd, # Validate that max_replicas is set to 0-30 if max_replicas is not None: if max_replicas < 1 or max_replicas > 30: - raise ArgumentUsageError('--max_replicas must be in the range [1,30]') + raise ArgumentUsageError('--max-replicas must be in the range [1,30]') if yaml: if image or min_replicas or max_replicas or\ From 7cd851aa25d72e8e9c678def0d484201d2c9e812 Mon Sep 17 00:00:00 2001 From: navba-MSFT <57353862+navba-MSFT@users.noreply.github.com> Date: Mon, 11 Jul 2022 13:12:03 +0530 Subject: [PATCH 5/5] {AzContainerApp} fixes Azure/azure-cli-extensions#5067 az containerapp update -n ContainerAppName -g ResourceGroup --min-replicas 0 --max-replicas 0 finishes without throwing any error, however scaling configuration is not updated as max replicas cannot be zero. This PR should include a fix to validate the --max-replicas field while the value is sent as Zero and raise CLIError fixes #5067 --- src/containerapp/azext_containerapp/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index d5b7a17042d..e6d003d13d6 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -508,7 +508,7 @@ def update_containerapp_logic(cmd, if max_replicas is not None: if max_replicas < 1 or max_replicas > 30: raise ArgumentUsageError('--max-replicas must be in the range [1,30]') - + if yaml: if image or min_replicas or max_replicas or\ set_env_vars or remove_env_vars or replace_env_vars or remove_all_env_vars or cpu or memory or\