Skip to content
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
43 changes: 23 additions & 20 deletions scripts/ci/credscan/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,29 @@
{
"file": [
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_basic_no_existing_resources.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_both_cpus_and_deploy_cpu.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_environment.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_deploy_cpu.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_environment_prompt.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_service_cpus.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_both.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_external.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets_and_existing_environment.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_internal.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets_and_existing_environment_conflict.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_prompt.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_transport_arg.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_registry_all_args.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_with_command_list.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_registry_server_arg_only.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_with_command_list_and_entrypoint.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_replicas_global_scale.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_with_command_string.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_replicas_replicated_mode.yaml"
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_location_differ_from_resource_group.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_environment.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_environment_prompt.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_both.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_external.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_internal.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_ingress_prompt.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_registry_all_args.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_registry_server_arg_only.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_replicas_global_scale.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_replicas_replicated_mode.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_both_cpus_and_deploy_cpu.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_deploy_cpu.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_deploy_with_mismatched_cpu_memory.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_service_cpus.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_resources_from_service_memory.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets_and_existing_environment.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets_and_existing_environment_conflict.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_create_with_transport_arg.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_with_command_list.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_with_command_list_and_entrypoint.yaml",
"src\\containerapp-compose\\azext_containerapp_compose\\tests\\latest\\recordings\\test_containerapp_compose_with_command_string.yaml"
],
"_justification": "Dummy resources' tokens left during testing."
}
Expand Down
5 changes: 5 additions & 0 deletions src/containerapp-compose/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.2.1
++++++
* Fix bug where location parameter was not being passed to containerapp environment creation
* Make memory/cpu resolution more resilient and improve warning messages

0.2.0
++++++
* Add basic build support for compose services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def override_random_log_analytics_name(resource_group_name): # pylint: disable=
def create_containerapps_compose_environment(cmd,
name,
resource_group_name,
location,
logs_workspace_name=None,
tags=None):
if logs_workspace_name is not None:
Expand All @@ -60,6 +61,7 @@ def create_containerapps_compose_environment(cmd,
return custom.create_managed_environment(cmd,
name,
resource_group_name,
location=location,
tags=tags)


Expand Down
45 changes: 35 additions & 10 deletions src/containerapp-compose/azext_containerapp_compose/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def create_containerapps_from_compose(cmd, # pylint: disable=R0914
managed_environment = create_containerapps_compose_environment(cmd,
managed_env,
resource_group_name,
location,
logs_workspace_name=logs_workspace_name,
tags=tags)

Expand Down Expand Up @@ -317,31 +318,55 @@ def valid_resource_settings():
# https://docs.microsoft.com/azure/container-apps/containers#configuration
return {
"0.25": "0.5",
"0.5": "1.0",
"0.5": "1",
"0.75": "1.5",
"1.0": "2.0",
"1.0": "2",
"1.25": "2.5",
"1.5": "3.0",
"1.5": "3",
"1.75": "3.5",
"2.0": "4.0",
"2.0": "4",
}


def validate_memory_and_cpu_setting(cpu, memory):
settings = valid_resource_settings()

if cpu in settings.keys(): # pylint: disable=C0201
if memory != settings[cpu]:
if memory is not None:
warning = f"Unsupported memory reservation request of {memory}."
warning += f"The default value of {settings[cpu]}Gi will be used."
warning = f"Unsupported memory reservation request of {memory}. "
warning += f"The default value of {settings[cpu]} GB for {cpu} vCPUs will be used. "
warning += "Please see memory and vCPU configuration options for Azure Container Apps at "
warning += "https://docs.microsoft.com/en-us/azure/container-apps/containers#configuration "
logger.warning(warning)
memory = settings[cpu]
return (cpu, f"{memory}Gi")

if cpu is not None:
logger.warning( # pylint: disable=W1203
f"Invalid CPU reservation request of {cpu}. The default resource values will be used.")
if memory in settings.values():
new_cpu = "0.25"
for c, m in settings.items():
if memory == m:
new_cpu = c
if cpu != new_cpu:
if cpu is not None:
warning = f"Unsupported cpu configuration request of {cpu}. "
warning += f"The default value of {new_cpu} vCPUs for {memory} GB will be used. "
warning += "Please see memory and vCPU configuration options for Azure Container Apps at "
warning += "https://docs.microsoft.com/en-us/azure/container-apps/containers#configuration "
logger.warning(warning)
return (new_cpu, f"{memory}Gi")

warning = ""
if cpu is not None and memory is not None:
warning += f"Invalid CPU and memory reservation request of {cpu} vCPU and {memory}. "
elif cpu is not None:
warning += f"Invalid CPU reservation request of {cpu} vCPU. "
elif memory is not None:
warning += f"Invalid memory reservation request of {memory} GB. "
if cpu is not None or memory is not None:
warning += "The default resource values of 0.25 vCPU and 0.5 GB will be used. "
warning += "Please see memory and vCPU configuration options for Azure Container Apps at "
warning += "https://docs.microsoft.com/en-us/azure/container-apps/containers#configuration "
logger.warning(warning)
return (None, None)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def clean_up_test_file(filename):

class ContainerappComposePreviewScenarioTest(ScenarioTest):
def setUp(self):
self.cmd("extension add --name containerapp --upgrade --yes")
self.cmd("extension add --name containerapp --upgrade --version 0.3.8 --yes")
return super().setUp()
Loading