Skip to content

Commit

Permalink
[Container app] az containerapp job update: Support job update in e…
Browse files Browse the repository at this point in the history
…xtension (#7656)
  • Loading branch information
Greedygre committed Jun 5, 2024
1 parent 134eb59 commit f09ee0b
Show file tree
Hide file tree
Showing 12 changed files with 6,131 additions and 6,954 deletions.
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release History
===============
upcoming
++++++
* 'az containerapp job update': Support command in extension
* 'az containerapp job logs show': Support log streaming for job execution
* 'az containerapp job replica list': Support list replicas of a job execution
* 'az containerapp env update': Fix logs configuration about removing destination with `--logs-destination none`
Expand Down
1 change: 1 addition & 0 deletions src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def load_command_table(self, args):
g.custom_show_command('show', 'show_containerappsjob')
g.custom_command('list', 'list_containerappsjob')
g.custom_command('create', 'create_containerappsjob', supports_no_wait=True, exception_handler=ex_handler_factory(), transform=transform_sensitive_values)
g.custom_command('update', 'update_containerappsjob', supports_no_wait=True, exception_handler=ex_handler_factory(), transform=transform_sensitive_values)
g.custom_command('delete', 'delete_containerappsjob', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp env certificate') as g:
Expand Down
488 changes: 484 additions & 4 deletions src/containerapp/azext_containerapp/containerapp_job_decorator.py

Large diffs are not rendered by default.

47 changes: 46 additions & 1 deletion src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from .containerapp_env_certificate_decorator import ContainerappPreviewEnvCertificateListDecorator, \
ContainerappEnvCertificatePreviweUploadDecorator
from .connected_env_decorator import ConnectedEnvironmentDecorator, ConnectedEnvironmentCreateDecorator
from .containerapp_job_decorator import ContainerAppJobPreviewCreateDecorator
from .containerapp_job_decorator import ContainerAppJobPreviewCreateDecorator, ContainerAppJobPreviewUpdateDecorator
from .containerapp_env_decorator import ContainerappEnvPreviewCreateDecorator, ContainerappEnvPreviewUpdateDecorator
from .containerapp_java_decorator import ContainerappJavaLoggerDecorator, ContainerappJavaLoggerSetDecorator, ContainerappJavaLoggerDeleteDecorator
from .containerapp_resiliency_decorator import (
Expand Down Expand Up @@ -948,6 +948,51 @@ def create_containerappsjob(cmd,
return r


def update_containerappsjob(cmd,
name,
resource_group_name,
yaml=None,
image=None,
container_name=None,
replica_timeout=None,
replica_retry_limit=None,
replica_completion_count=None,
parallelism=None,
cron_expression=None,
set_env_vars=None,
remove_env_vars=None,
replace_env_vars=None,
remove_all_env_vars=False,
cpu=None,
memory=None,
startup_command=None,
args=None,
scale_rule_metadata=None,
scale_rule_name=None,
scale_rule_type=None,
scale_rule_auth=None,
polling_interval=None,
min_executions=None,
max_executions=None,
tags=None,
workload_profile_name=None,
no_wait=False):
raw_parameters = locals()

containerapp_job_update_decorator = ContainerAppJobPreviewUpdateDecorator(
cmd=cmd,
client=ContainerAppsJobPreviewClient,
raw_parameters=raw_parameters,
models=CONTAINER_APPS_SDK_MODELS
)
containerapp_job_update_decorator.validate_subscription_registered(CONTAINER_APPS_RP)
containerapp_job_update_decorator.validate_arguments()

containerapp_job_update_decorator.construct_payload()
r = containerapp_job_update_decorator.update()
return r


def show_containerappsjob(cmd, name, resource_group_name):
raw_parameters = locals()
containerapp_job_decorator = ContainerAppJobDecorator(
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.

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def test_containerappjob_create_with_yaml(self, resource_group):
replicaRetryLimit: 1
replicaTimeout: 100
scheduleTriggerConfig: null
secrets: null
secrets:
- name: secret1
value: 1
triggerType: Manual
template:
containers:
Expand Down Expand Up @@ -141,6 +143,7 @@ def test_containerappjob_create_with_yaml(self, resource_group):
JMESPathCheck("properties.configuration.triggerType", "Manual", case_sensitive=False),
JMESPathCheck('properties.configuration.replicaTimeout', 100),
JMESPathCheck('properties.configuration.replicaRetryLimit', 1),
JMESPathCheck("length(properties.configuration.secrets)", 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"),
Expand Down Expand Up @@ -177,7 +180,10 @@ def test_containerappjob_create_with_yaml(self, resource_group):
replicaRetryLimit: 1
replicaTimeout: 200
scheduleTriggerConfig: null
secrets: null
secrets:
- name: secret1
- name: secret2
value: 123
triggerType: Manual
template:
containers:
Expand Down Expand Up @@ -228,6 +234,7 @@ def test_containerappjob_create_with_yaml(self, resource_group):
JMESPathCheck("properties.configuration.triggerType", "Manual", case_sensitive=False),
JMESPathCheck('properties.configuration.replicaTimeout', 200),
JMESPathCheck('properties.configuration.replicaRetryLimit', 1),
JMESPathCheck("length(properties.configuration.secrets)", 2),
JMESPathCheck('properties.template.containers[0].image', "mcr.microsoft.com/k8se/quickstart-jobs:latest"),
JMESPathCheck('properties.template.containers[0].resources.cpu', "0.75"),
JMESPathCheck('properties.template.containers[0].resources.memory', "1.5Gi"),
Expand All @@ -240,6 +247,16 @@ def test_containerappjob_create_with_yaml(self, resource_group):
JMESPathCheck('properties.template.containers[0].volumeMounts[0].volumeName', 'azure-files-volume'),
])

self.cmd(f'containerapp job secret show -g {resource_group} -n {job} --secret-name secret1', checks=[
JMESPathCheck("name", 'secret1'),
JMESPathCheck("value", '1'),
])

self.cmd(f'containerapp job secret show -g {resource_group} -n {job} --secret-name secret2', checks=[
JMESPathCheck("name", 'secret2'),
JMESPathCheck("value", '123'),
])

# wait for provisioning state of job to be succeeded before updating
jobProvisioning = True
timeout = time.time() + 60*1 # 1 minutes from now
Expand Down

0 comments on commit f09ee0b

Please sign in to comment.