Skip to content

Commit

Permalink
Add support for scale
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
jldeen authored May 13, 2022
1 parent d88bbcf commit 7cda26e
Show file tree
Hide file tree
Showing 5 changed files with 3,786 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/ci/credscan/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@
"src\\containerapp-preview\\azext_containerapp_preview\\tests\\latest\\recordings\\test_containerapp_compose_create_with_registry_server_arg_only.yaml",
"src\\containerapp-preview\\azext_containerapp_preview\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets.yaml",
"src\\containerapp-preview\\azext_containerapp_preview\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets_and_existing_environment.yaml",
"src\\containerapp-preview\\azext_containerapp_preview\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets_and_existing_environment_conflict.yaml"
"src\\containerapp-preview\\azext_containerapp_preview\\tests\\latest\\recordings\\test_containerapp_compose_create_with_secrets_and_existing_environment_conflict.yaml",
"src\\containerapp-preview\\azext_containerapp_preview\\tests\\latest\\recordings\\test_containerapp_compose_create_with_replicas_global_scale.yaml",
"src\\containerapp-preview\\azext_containerapp_preview\\tests\\latest\\recordings\\test_containerapp_compose_create_with_replicas_replicated_mode.yaml"

],
"_justification": "Dummy resources' tokens left during testing."
Expand Down
17 changes: 17 additions & 0 deletions src/containerapp-preview/azext_containerapp_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def create_containerapps_from_compose(cmd, # pylint: disable=R0914
resolve_cpu_configuration_from_service(service),
resolve_memory_configuration_from_service(service)
)
replicas = resolve_replicas_from_service(service)
environment = resolve_environment_from_service(service)
secret_vars, secret_env_ref = resolve_secret_from_service(service, parsed_compose_file.secrets)
if environment is not None and secret_env_ref is not None:
Expand All @@ -93,6 +94,8 @@ def create_containerapps_from_compose(cmd, # pylint: disable=R0914
memory=memory,
env_vars=environment,
secrets=secret_vars,
min_replicas=replicas,
max_replicas=replicas,
))

return containerapps_from_compose
Expand Down Expand Up @@ -176,6 +179,20 @@ def resolve_secret_from_service(service, secrets_map):
return (secret_array, secret_env_ref)


def resolve_replicas_from_service(service):
replicas = None

if service.scale:
replicas = service.scale
if service_deploy_exists(service):
if service.deploy.replicas is not None:
replicas = service.deploy.replicas
if service.deploy.mode == "global":
replicas = 1

return replicas


def valid_resource_settings():
# vCPU and Memory reservations
# https://docs.microsoft.com/azure/container-apps/containers#configuration
Expand Down
Loading

0 comments on commit 7cda26e

Please sign in to comment.