diff --git a/src/containerapp/HISTORY.rst b/src/containerapp/HISTORY.rst index 00bda2a66ef..cdfaabe70fb 100644 --- a/src/containerapp/HISTORY.rst +++ b/src/containerapp/HISTORY.rst @@ -8,6 +8,7 @@ Upcoming * 'az containerapp job start': update start execution payload format to exlude template property from API version 2023-05-01 onwards * 'az containerapp service': add support for creation and deletion of MariaDB * 'az containerapp create/list': support --environment-type parameter +* 'az containerapp logs show': fix raising error for response status code is not OK 0.3.36 ++++++ diff --git a/src/containerapp/azext_containerapp/_up_utils.py b/src/containerapp/azext_containerapp/_up_utils.py index 8a984251efc..89f2891272d 100644 --- a/src/containerapp/azext_containerapp/_up_utils.py +++ b/src/containerapp/azext_containerapp/_up_utils.py @@ -324,7 +324,6 @@ def create(self, no_registry=False): resource_group_name=self.resource_group.name, image=self.image, managed_env=self.env.get_rid(), - target_port=self.target_port, registry_server=None if no_registry else self.registry_server, registry_pass=None if no_registry else self.registry_pass, registry_user=None if no_registry else self.registry_user, diff --git a/src/containerapp/azext_containerapp/containerapp_decorator.py b/src/containerapp/azext_containerapp/containerapp_decorator.py index 46db03ff7e3..48f811b19b6 100644 --- a/src/containerapp/azext_containerapp/containerapp_decorator.py +++ b/src/containerapp/azext_containerapp/containerapp_decorator.py @@ -338,7 +338,7 @@ def validate_arguments(self): validate_create(self.get_argument_registry_identity(), self.get_argument_registry_pass(), self.get_argument_registry_user(), self.get_argument_registry_server(), self.get_argument_no_wait()) validate_revision_suffix(self.get_argument_revision_suffix()) - def construct_containerapp(self): + def construct_payload(self): if self.get_argument_registry_identity() and not is_registry_msi_system(self.get_argument_registry_identity()): logger.info("Creating an acrpull role assignment for the registry identity") create_acrpull_role_assignment(self.cmd, self.get_argument_registry_server(), self.get_argument_registry_identity(), skip_error=True) @@ -545,7 +545,7 @@ def construct_containerapp(self): else: set_managed_identity(self.cmd, self.get_argument_resource_group_name(), self.containerapp_def, user_assigned=[self.get_argument_registry_identity()]) - def create_containerapp(self): + def create(self): try: r = self.client.create_or_update( cmd=self.cmd, resource_group_name=self.get_argument_resource_group_name(), name=self.get_argument_name(), container_app_envelope=self.containerapp_def, @@ -555,7 +555,7 @@ def create_containerapp(self): except Exception as e: handle_raw_exception(e) - def construct_containerapp_for_post_process(self, r): + def construct_for_post_process(self, r): if is_registry_msi_system(self.get_argument_registry_identity()): while r["properties"]["provisioningState"] == "InProgress": r = self.client.show(self.cmd, self.get_argument_resource_group_name(), self.get_argument_name()) @@ -573,9 +573,9 @@ def construct_containerapp_for_post_process(self, r): registries_def["identity"] = self.get_argument_registry_identity() safe_set(self.containerapp_def, "properties", "configuration", "registries", value=[registries_def]) - def post_process_containerapp(self, r): + def post_process(self, r): if is_registry_msi_system(self.get_argument_registry_identity()): - r = self.create_containerapp() + r = self.create() if "properties" in r and "provisioningState" in r["properties"] and r["properties"]["provisioningState"].lower() == "waiting" and not self.get_argument_no_wait(): not self.get_argument_disable_warnings() and logger.warning('Containerapp creation in progress. Please monitor the creation using `az containerapp show -n {} -g {}`'.format(self.get_argument_name(), self.get_argument_resource_group_name())) @@ -734,8 +734,8 @@ def __init__( ): super().__init__(cmd, client, raw_parameters, models) - def construct_containerapp(self): - super().construct_containerapp() + def construct_payload(self): + super().construct_payload() self.set_up_extended_location() def set_up_extended_location(self): diff --git a/src/containerapp/azext_containerapp/containerapp_job_decorator.py b/src/containerapp/azext_containerapp/containerapp_job_decorator.py index 1a3c8fb1cb1..b390226dfba 100644 --- a/src/containerapp/azext_containerapp/containerapp_job_decorator.py +++ b/src/containerapp/azext_containerapp/containerapp_job_decorator.py @@ -218,6 +218,8 @@ def post_process(self, r): if "properties" in r and "provisioningState" in r["properties"] and r["properties"]["provisioningState"].lower() == "waiting" and not self.get_argument_no_wait(): not self.get_argument_disable_warnings() and logger.warning('Containerapp job creation in progress. Please monitor the creation using `az containerapp job show -n {} -g {}`'.format(self.get_argument_name, self.get_argument_resource_group_name())) + return r + def construct_payload(self): if self.get_argument_registry_identity() and not is_registry_msi_system(self.get_argument_registry_identity()): logger.info("Creating an acrpull role assignment for the registry identity") diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index 21aed1f9047..d9302eff79e 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -487,10 +487,10 @@ def create_containerapp(cmd, containerapp_create_decorator.register_provider(CONTAINER_APPS_RP) containerapp_create_decorator.validate_arguments() - containerapp_create_decorator.construct_containerapp() - r = containerapp_create_decorator.create_containerapp() - containerapp_create_decorator.construct_containerapp_for_post_process(r) - r = containerapp_create_decorator.post_process_containerapp(r) + containerapp_create_decorator.construct_payload() + r = containerapp_create_decorator.create() + containerapp_create_decorator.construct_for_post_process(r) + r = containerapp_create_decorator.post_process(r) return r @@ -3804,7 +3804,7 @@ def stream_containerapp_logs(cmd, resource_group_name, name, container=None, rev headers=headers) if not resp.ok: - ValidationError(f"Got bad status from the logstream API: {resp.status_code}") + raise ValidationError(f"Got bad status from the logstream API: {resp.status_code}") for line in resp.iter_lines(): if line: diff --git a/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_crud.py b/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_crud.py index 41e44c2e365..771dca66c27 100644 --- a/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_crud.py +++ b/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_crud.py @@ -50,7 +50,15 @@ def test_containerapp_manualjob_crudoperations_e2e(self, resource_group): self.assertTrue(len(jobs_list) == 1) # update the Container App Job resource - self.cmd("az containerapp job update --resource-group {} --name {} --replica-timeout 300 --replica-retry-limit 1 --image mcr.microsoft.com/k8se/quickstart-jobs:latest --cpu '0.5' --memory '1.0Gi'".format(resource_group, job)) + self.cmd("az containerapp job update --resource-group {} --name {} --replica-timeout 300 --replica-retry-limit 1 --image mcr.microsoft.com/k8se/quickstart-jobs:latest --cpu '0.5' --memory '1.0Gi'".format(resource_group, job), checks=[ + JMESPathCheck('name', job), + JMESPathCheck('properties.configuration.replicaTimeout', 300), + JMESPathCheck('properties.configuration.replicaRetryLimit', 1), + JMESPathCheck('properties.configuration.triggerType', "manual", case_sensitive=False), + JMESPathCheck('properties.template.containers[0].image', "mcr.microsoft.com/k8se/quickstart-jobs:latest"), + JMESPathCheck('properties.template.containers[0].resources.cpu', "0.5"), + JMESPathCheck('properties.template.containers[0].resources.memory', "1Gi"), + ]) # verify the updated Container App Job resource self.cmd("az containerapp job show --resource-group {} --name {}".format(resource_group, job), checks=[ diff --git a/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_with_yaml.py b/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_with_yaml.py index 1477d420316..1fdd2fa0d4c 100644 --- a/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_with_yaml.py +++ b/src/containerapp/azext_containerapp/tests/latest/test_containerappjob_with_yaml.py @@ -109,7 +109,23 @@ def test_containerappjob_create_with_yaml(self, resource_group): containerappjob_file_name = f"{self._testMethodName}_containerappjob.yml" write_test_file(containerappjob_file_name, containerappjob_yaml_text) - self.cmd(f'containerapp job create -n {job} -g {resource_group} --environment {env} --yaml {containerappjob_file_name}') + self.cmd(f'containerapp job create -n {job} -g {resource_group} --environment {env} --yaml {containerappjob_file_name}', checks=[ + JMESPathCheck("properties.provisioningState", "Succeeded"), + JMESPathCheck("properties.configuration.triggerType", "Manual", case_sensitive=False), + JMESPathCheck('properties.configuration.replicaTimeout', 100), + JMESPathCheck('properties.configuration.replicaRetryLimit', 1), + JMESPathCheck('properties.template.containers[0].image', "mcr.microsoft.com/k8se/quickstart-jobs:latest"), + JMESPathCheck('properties.template.containers[0].resources.cpu', "0.5"), + JMESPathCheck('properties.template.containers[0].resources.memory', "1Gi"), + JMESPathCheck('identity.type', "UserAssigned"), + JMESPathCheck('properties.template.volumes[0].storageType', 'AzureFile'), + JMESPathCheck('properties.template.volumes[0].storageName', share), + JMESPathCheck('properties.template.volumes[0].name', 'azure-files-volume'), + JMESPathCheck('properties.template.volumes[0].mountOptions', 'uid=999,gid=999'), + JMESPathCheck('properties.template.containers[0].volumeMounts[0].subPath', 'sub'), + JMESPathCheck('properties.template.containers[0].volumeMounts[0].mountPath', '/mnt/data'), + JMESPathCheck('properties.template.containers[0].volumeMounts[0].volumeName', 'azure-files-volume') + ]) self.cmd(f'containerapp job show -g {resource_group} -n {job}', checks=[ JMESPathCheck("properties.provisioningState", "Succeeded"),