Skip to content

Commit

Permalink
[containerapp] az containerapp env create: Update the default value…
Browse files Browse the repository at this point in the history
… of `--enable-workload-profiles` to `True` (#27680)
  • Loading branch information
Greedygre authored Nov 1, 2023
1 parent b569674 commit e7cbc62
Show file tree
Hide file tree
Showing 110 changed files with 192,651 additions and 207,399 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
logger = get_logger(__name__)

CURRENT_API_VERSION = "2023-05-01"
POLLING_TIMEOUT = 600 # how many seconds before exiting
POLLING_TIMEOUT = 1200 # how many seconds before exiting
POLLING_SECONDS = 2 # how many seconds between requests
POLLING_TIMEOUT_FOR_MANAGED_CERTIFICATE = 1500 # how many seconds before exiting
POLLING_INTERVAL_FOR_MANAGED_CERTIFICATE = 4 # how many seconds between requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ def validate_memory_and_cpu_setting(cpu, memory, managed_environment):
# only v1 cluster do the validation
from ._utils import safe_get
if safe_get(managed_environment, "properties", "workloadProfiles"):
if memory:
return cpu, f"{memory}Gi"
return cpu, memory

settings = valid_resource_settings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def load_arguments(self, _):

with self.argument_context('containerapp env create') as c:
c.argument('zone_redundant', options_list=["--zone-redundant", "-z"], help="Enable zone redundancy on the environment. Cannot be used without --infrastructure-subnet-resource-id. If used with --location, the subnet's location must match")
c.argument('enable_workload_profiles', arg_type=get_three_state_flag(), options_list=["--enable-workload-profiles", "-w"], help="Boolean indicating if the environment is enabled to have workload profiles", default=False)
c.argument('enable_workload_profiles', arg_type=get_three_state_flag(), options_list=["--enable-workload-profiles", "-w"], help="Boolean indicating if the environment is enabled to have workload profiles")

with self.argument_context('containerapp env update') as c:
c.argument('name', name_type, help='Name of the Container Apps environment.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
load_cert_file,
safe_set,
get_default_workload_profiles,
_azure_monitor_quickstart)
from ._client_factory import handle_raw_exception
_azure_monitor_quickstart, safe_get)
from ._client_factory import handle_raw_exception, handle_non_404_status_code_exception
from .base_resource import BaseResource
from ._models import (
ManagedEnvironment as ManagedEnvironmentModel,
Expand Down Expand Up @@ -189,6 +189,23 @@ def construct_payload(self):

def set_up_workload_profiles(self):
if self.get_argument_enable_workload_profiles():
# If the environment exists, infer the environment type
existing_environment = None
try:
existing_environment = self.client.show(cmd=self.cmd,
resource_group_name=self.get_argument_resource_group_name(),
name=self.get_argument_name())
except Exception as e:
handle_non_404_status_code_exception(e)

if existing_environment and safe_get(existing_environment, "properties", "workloadProfiles") is None:
# check if input params include -w/--enable-workload-profiles
if self.cmd.cli_ctx.data.get('safe_params') and ('-w' in self.cmd.cli_ctx.data.get(
'safe_params') or '--enable-workload-profiles' in self.cmd.cli_ctx.data.get('safe_params')):
raise ValidationError(
f"Existing environment {self.get_argument_name()} cannot enable workload profiles. If you want to use Consumption and Dedicated environment, please create a new one.")
return

self.managed_env_def["properties"]["workloadProfiles"] = get_default_workload_profiles(self.cmd, self.get_argument_location())

def set_up_app_log_configuration(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def create_managed_environment(cmd,
hostname=None,
certificate_file=None,
certificate_password=None,
enable_workload_profiles=False,
enable_workload_profiles=True,
mtls_enabled=None,
no_wait=False):
raw_parameters = locals()
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@


from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, LogAnalyticsWorkspacePreparer)
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)

from .common import TEST_LOCATION
from .utils import create_containerapp_env
from .utils import prepare_containerapp_env_for_app_e2e_tests


# flake8: noqa
# noqa
Expand All @@ -21,15 +22,13 @@ def __init__(self, *arg, **kwargs):

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location=TEST_LOCATION)
@LogAnalyticsWorkspacePreparer(location="eastus", get_shared_key=True)
def test_containerapp_auth_e2e(self, resource_group, laworkspace_customer_id, laworkspace_shared_key):
def test_containerapp_auth_e2e(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
env = self.create_random_name(prefix='containerapp-env', length=24)
app = self.create_random_name(prefix='containerapp-auth', length=24)

create_containerapp_env(self, env, resource_group, logs_workspace=laworkspace_customer_id, logs_workspace_shared_key=laworkspace_shared_key)
env_id = prepare_containerapp_env_for_app_e2e_tests(self)

self.cmd('containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(resource_group, app, env))
self.cmd('containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(resource_group, app, env_id))

client_id = 'abc123'
test_secret = 'abc123'
Expand Down Expand Up @@ -102,17 +101,15 @@ def test_containerapp_auth_e2e(self, resource_group, laworkspace_customer_id, la

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location=TEST_LOCATION)
@LogAnalyticsWorkspacePreparer(location="eastus", get_shared_key=True)
def test_containerapp_auth_facebook_e2e(self, resource_group, laworkspace_customer_id, laworkspace_shared_key):
def test_containerapp_auth_facebook_e2e(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
env = self.create_random_name(prefix='containerapp-env', length=24)
app = self.create_random_name(prefix='containerapp-auth', length=24)

create_containerapp_env(self, env, resource_group, logs_workspace=laworkspace_customer_id, logs_workspace_shared_key=laworkspace_shared_key)
env_id = prepare_containerapp_env_for_app_e2e_tests(self)

self.cmd(
'containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(
resource_group, app, env))
resource_group, app, env_id))

app_id = 'abc123'
test_secret = 'abc123'
Expand Down Expand Up @@ -141,17 +138,15 @@ def test_containerapp_auth_facebook_e2e(self, resource_group, laworkspace_custom

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location=TEST_LOCATION)
@LogAnalyticsWorkspacePreparer(location="eastus", get_shared_key=True)
def test_containerapp_auth_github_e2e(self, resource_group, laworkspace_customer_id, laworkspace_shared_key):
def test_containerapp_auth_github_e2e(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
env = self.create_random_name(prefix='containerapp-env', length=24)
app = self.create_random_name(prefix='containerapp-auth', length=24)

create_containerapp_env(self, env, resource_group, logs_workspace=laworkspace_customer_id, logs_workspace_shared_key=laworkspace_shared_key)
env_id = prepare_containerapp_env_for_app_e2e_tests(self)

self.cmd(
'containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(
resource_group, app, env))
resource_group, app, env_id))

client_id = 'abc123'
test_secret = 'abc123'
Expand All @@ -175,7 +170,7 @@ def test_containerapp_auth_github_e2e(self, resource_group, laworkspace_customer

self.cmd(
'containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(
resource_group, app, env))
resource_group, app, env_id))

self.cmd(
'containerapp auth google update -g {} --name {} --client-id {} --client-secret {} --yes'
Expand All @@ -195,7 +190,7 @@ def test_containerapp_auth_github_e2e(self, resource_group, laworkspace_customer

self.cmd(
'containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(
resource_group, app, env))
resource_group, app, env_id))

self.cmd(
'containerapp auth apple update -g {} --name {} --client-id {} --client-secret {} --yes'
Expand All @@ -215,7 +210,7 @@ def test_containerapp_auth_github_e2e(self, resource_group, laworkspace_customer

self.cmd(
'containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(
resource_group, app, env))
resource_group, app, env_id))

self.cmd(
'containerapp auth twitter update -g {} --name {} --consumer-key {} --consumer-secret {} --yes'
Expand All @@ -238,17 +233,15 @@ def test_containerapp_auth_github_e2e(self, resource_group, laworkspace_customer

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location=TEST_LOCATION)
@LogAnalyticsWorkspacePreparer(location="eastus", get_shared_key=True)
def test_containerapp_auth_openid_connect_e2e(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
env = self.create_random_name(prefix='containerapp-env', length=24)
app = self.create_random_name(prefix='containerapp-auth', length=24)

create_containerapp_env(self, env, resource_group)
env_id = prepare_containerapp_env_for_app_e2e_tests(self)

self.cmd(
'containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(
resource_group, app, env))
resource_group, app, env_id))

client_id = 'abc123'
test_secret = 'abc123'
Expand All @@ -257,7 +250,7 @@ def test_containerapp_auth_openid_connect_e2e(self, resource_group):
app = self.create_random_name(prefix='containerapp-auth', length=24)
self.cmd(
'containerapp create -g {} -n {} --environment {} --image mcr.microsoft.com/k8se/quickstart:latest --ingress external --target-port 80'.format(
resource_group, app, env))
resource_group, app, env_id))

provider_name = "customopenid"
configuration = "test-openid-configuration"
Expand Down
Loading

0 comments on commit e7cbc62

Please sign in to comment.