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 2 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
7 changes: 6 additions & 1 deletion src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

Release History
===============
Upcoming
0.3.29
++++++
* 'az containerapp update'/'az containerapp env update': fix --no-wait
* 'az containerapp update': fix the --yaml update behavior to respect the empty array in patch-request
* Remove 'az containerapp env workload-profile set' split into 'az containerapp env workload-profile add' and 'az containerapp env workload-profile update'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Remove 'az containerapp env workload-profile set' split into 'az containerapp env workload-profile add' and 'az containerapp env workload-profile update'
* 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


0.3.28
++++++
Expand Down
17 changes: 13 additions & 4 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,22 @@
az containerapp env workload-profile list-supported -l region
"""

helps['containerapp env workload-profile set'] = """
helps['containerapp env workload-profile add'] = """
type: command
short-summary: Create or update an existing workload profile in a Container Apps environment
short-summary: Create a workload profile in a Container Apps environment
examples:
- name: Create or update an existing workload profile in a Container Apps environment
- name: Create a workload profile in a Container Apps environment
text: |
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
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
Expand Down
9 changes: 7 additions & 2 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,12 @@ def load_arguments(self, _):
c.argument('env_name', options_list=['--name', '-n'], help="The name of the Container App environment")
c.argument('workload_profile_name', options_list=['--workload-profile-name', '-w'], help='The friendly name for the workload profile')

with self.argument_context('containerapp env workload-profile set') as c:
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.")
p-bouchon marked this conversation as resolved.
Show resolved Hide resolved
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")
3 changes: 2 additions & 1 deletion src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,6 @@ 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('add', 'add_workload_profile')
g.custom_command('update', 'update_workload_profile')
g.custom_command('delete', 'delete_workload_profile')
33 changes: 30 additions & 3 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4040,8 +4040,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 @@ -4202,7 +4201,35 @@ def show_workload_profile(cmd, resource_group_name, env_name, workload_profile_n
return profile[0]


def set_workload_profile(cmd, resource_group_name, env_name, workload_profile_name, workload_profile_type=None, min_nodes=None, max_nodes=None):
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)


Expand Down
Loading