Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pbouchon/wlp bugs #6243

Merged
merged 9 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Release History
===============
Upcoming
++++++
* Split 'az containerapp env workload-profile set' into 'az containerapp env workload-profile add' and 'az containerapp env workload-profile update'
* Add 'az containerapp env workload-profile add' to support creating a workload profile in an environment
* Add 'az containerapp env workload-profile update' to support updating an existing workload profile in an environment
* 'az containerapp auth update': fix excluded paths first and last character being cutoff
* 'az containerapp update': remove the environmentId in the PATCH payload if it has not been changed
* Upgrade api-version to 2023-04-01-preview

Expand Down
18 changes: 18 additions & 0 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,24 @@
az containerapp env workload-profile set -g MyResourceGroup -n MyEnvironment --workload-profile-name my-wlp --workload-profile-type D4 --min-nodes 1 --max-nodes 2
"""

helps['containerapp env workload-profile add'] = """
type: command
short-summary: Create a workload profile in a Container Apps environment
examples:
- name: Create a workload profile in a Container Apps environment
text: |
az containerapp env workload-profile add -g MyResourceGroup -n MyEnvironment --workload-profile-name my-wlp --workload-profile-type D4 --min-nodes 1 --max-nodes 2
"""

helps['containerapp env workload-profile update'] = """
type: command
short-summary: Update an existing workload profile in a Container Apps environment
examples:
- name: Update an existing workload profile in a Container Apps environment
text: |
az containerapp env workload-profile update -g MyResourceGroup -n MyEnvironment --workload-profile-name my-wlp --workload-profile-type D4 --min-nodes 1 --max-nodes 3
"""

# Certificates Commands
helps['containerapp env certificate'] = """
type: group
Expand Down
10 changes: 10 additions & 0 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,13 @@ def load_arguments(self, _):
c.argument('workload_profile_type', help="The type of workload profile to add or update. Run 'az containerapp env workload-profile list-supported -l <region>' to check the options for your region.")
c.argument('min_nodes', help="The minimum node count for the workload profile")
c.argument('max_nodes', help="The maximum node count for the workload profile")

with self.argument_context('containerapp env workload-profile add') as c:
c.argument('workload_profile_type', help="The type of workload profile to add to this environment. Run 'az containerapp env workload-profile list-supported -l <region>' to check the options for your region.")
c.argument('min_nodes', help="The minimum node count for the workload profile")
c.argument('max_nodes', help="The maximum node count for the workload profile")

with self.argument_context('containerapp env workload-profile update') as c:
c.argument('workload_profile_type', help="The type of workload profile to update. Run 'az containerapp env workload-profile list-supported -l <region>' to check the options for your region.")
c.argument('min_nodes', help="The minimum node count for the workload profile")
c.argument('max_nodes', help="The maximum node count for the workload profile")
4 changes: 3 additions & 1 deletion src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,7 @@ def load_command_table(self, _):
g.custom_command('list-supported', 'list_supported_workload_profiles')
g.custom_command('list', 'list_workload_profiles')
g.custom_show_command('show', 'show_workload_profile')
g.custom_command('set', 'set_workload_profile')
g.custom_command('set', 'set_workload_profile', deprecate_info=g.deprecate(hide=True))
g.custom_command('add', 'add_workload_profile')
g.custom_command('update', 'update_workload_profile')
g.custom_command('delete', 'delete_workload_profile')
35 changes: 33 additions & 2 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4112,8 +4112,7 @@ def update_auth_config(cmd, resource_group_name, name, set_string=None, enabled=
if excluded_paths is not None:
if "globalValidation" not in existing_auth:
existing_auth["globalValidation"] = {}
excluded_paths_list_string = excluded_paths[1:-1]
existing_auth["globalValidation"]["excludedPaths"] = excluded_paths_list_string.split(",")
existing_auth["globalValidation"]["excludedPaths"] = excluded_paths.split(",")

existing_auth = update_http_settings_in_auth_settings(existing_auth, require_https,
proxy_convention, proxy_custom_host_header,
Expand Down Expand Up @@ -4278,6 +4277,38 @@ def set_workload_profile(cmd, resource_group_name, env_name, workload_profile_na
return update_managed_environment(cmd, env_name, resource_group_name, workload_profile_type=workload_profile_type, workload_profile_name=workload_profile_name, min_nodes=min_nodes, max_nodes=max_nodes)


def add_workload_profile(cmd, resource_group_name, env_name, workload_profile_name, workload_profile_type=None, min_nodes=None, max_nodes=None):
try:
r = ManagedEnvironmentClient.show(cmd=cmd, resource_group_name=resource_group_name, name=env_name)
except CLIError as e:
handle_raw_exception(e)

workload_profiles = r["properties"]["workloadProfiles"]

workload_profiles_lower = [p["name"].lower() for p in workload_profiles]

if workload_profile_name.lower() in workload_profiles_lower:
raise ValidationError(f"Cannot add workload profile with name {workload_profile_name} because it already exists in this environment")

return update_managed_environment(cmd, env_name, resource_group_name, workload_profile_type=workload_profile_type, workload_profile_name=workload_profile_name, min_nodes=min_nodes, max_nodes=max_nodes)


def update_workload_profile(cmd, resource_group_name, env_name, workload_profile_name, workload_profile_type=None, min_nodes=None, max_nodes=None):
try:
r = ManagedEnvironmentClient.show(cmd=cmd, resource_group_name=resource_group_name, name=env_name)
except CLIError as e:
handle_raw_exception(e)

workload_profiles = r["properties"]["workloadProfiles"]

workload_profiles_lower = [p["name"].lower() for p in workload_profiles]

if workload_profile_name.lower() not in workload_profiles_lower:
raise ValidationError(f"Workload profile with name {workload_profile_name} does not exist in this environment. The workload profiles available in this environment are {','.join([p['name'] for p in workload_profiles])}")

return update_managed_environment(cmd, env_name, resource_group_name, workload_profile_type=workload_profile_type, workload_profile_name=workload_profile_name, min_nodes=min_nodes, max_nodes=max_nodes)


def delete_workload_profile(cmd, resource_group_name, env_name, workload_profile_name):
try:
r = ManagedEnvironmentClient.show(cmd=cmd, resource_group_name=resource_group_name, name=env_name)
Expand Down
Loading