Skip to content

Commit

Permalink
[containerapp] az containerapp job create: Add default values for pro…
Browse files Browse the repository at this point in the history
…perties (Azure#6789)
  • Loading branch information
p-bouchon committed Oct 12, 2023
1 parent e25ca1a commit edfe5b6
Show file tree
Hide file tree
Showing 9 changed files with 4,312 additions and 3,096 deletions.
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ upcoming
* 'az containerapp update': fix bug for mounting secret volumes using --secret-volume-mount
* 'az containerapp compose create': fixed an issue where the environment's resource group was not resolved from --environment when the input value was a resource id.
* 'az containerapp replica count', returns the replica count of a container app
[Breaking Change] 'az containerapp job create': add default values for container app job properties --replica-completion-count, --replica-retry-limit, --replica-timeout, --parallelism, --min-executions, --max-executions, --polling-interval

0.3.41
++++++
Expand Down
21 changes: 14 additions & 7 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,19 +485,26 @@ def load_arguments(self, _):
c.argument('name', name_type, metavar='NAME', id_part='name', help=f"The name of the Container Apps Job. A name must consist of lower case alphanumeric characters or '-', start with a letter, end with an alphanumeric character, cannot have '--', and must be less than {MAXIMUM_CONTAINER_APP_NAME_LENGTH} characters.")
c.argument('cron_expression', help='Cron expression. Only supported for trigger type "Schedule"')
c.argument('image', help="Container image, e.g. publisher/image-name:tag.")
c.argument('replica_completion_count', type=int, options_list=['--replica-completion-count', '--rcc'], help='Number of replicas that need to complete successfully for execution to succeed.')
c.argument('replica_retry_limit', type=int, help='Maximum number of retries before the replica fails.')
c.argument('replica_timeout', type=int, help='Maximum number of seconds a replica can execute.')
c.argument('parallelism', type=int, help='Maximum number of replicas to run per execution.')
c.argument('replica_completion_count', type=int, options_list=['--replica-completion-count', '--rcc'], help='Number of replicas that need to complete successfully for execution to succeed')
c.argument('replica_retry_limit', type=int, help='Maximum number of retries before the replica fails')
c.argument('replica_timeout', type=int, help='Maximum number of seconds a replica can execute')
c.argument('parallelism', type=int, help='Maximum number of replicas to run per execution')
c.argument('workload_profile_name', options_list=['--workload-profile-name', '-w'], help='The friendly name for the workload profile')
c.argument('min_executions', type=int, help="Minimum number of job executions that are created for a trigger, default 0.")
c.argument('max_executions', type=int, help="Maximum number of job executions that are created for a trigger, default 100.")
c.argument('polling_interval', type=int, help="Interval to check each event source in seconds. Defaults to 30s.", default=30)
c.argument('min_executions', type=int, help="Minimum number of job executions that are created for a trigger")
c.argument('max_executions', type=int, help="Maximum number of job executions that are created for a trigger")
c.argument('polling_interval', type=int, help="Interval to check each event source in seconds.")

with self.argument_context('containerapp job create') as c:
c.argument('system_assigned', options_list=['--mi-system-assigned', c.deprecate(target='--system-assigned', redirect='--mi-system-assigned', hide=True)], help='Boolean indicating whether to assign system-assigned identity.', action='store_true')
c.argument('trigger_type', help='Trigger type. Schedule | Event | Manual')
c.argument('user_assigned', options_list=['--mi-user-assigned', c.deprecate(target='--user-assigned', redirect='--mi-user-assigned', hide=True)], nargs='+', help='Space-separated user identities to be assigned.')
c.argument('replica_completion_count', type=int, options_list=['--replica-completion-count', '--rcc'], help='Number of replicas that need to complete successfully for execution to succeed', default=1)
c.argument('replica_retry_limit', type=int, help='Maximum number of retries before the replica fails. Default: 0.', default=0)
c.argument('replica_timeout', type=int, help='Maximum number of seconds a replica can execute', default=1800)
c.argument('parallelism', type=int, help='Maximum number of replicas to run per execution', default=1)
c.argument('min_executions', type=int, help="Minimum number of job executions that are created for a trigger. Default: 0.", default=0)
c.argument('max_executions', type=int, help="Maximum number of job executions that are created for a trigger", default=100)
c.argument('polling_interval', type=int, help="Interval to check each event source in seconds.", default=30)

with self.argument_context('containerapp job', arg_group='Scale') as c:
c.argument('min_executions', type=int, help="Minimum number of job executions to run per polling interval.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ def validate_arguments(self):
validate_container_app_name(self.get_argument_name(), AppType.ContainerAppJob.name)
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())
if self.get_argument_yaml() is None:
if self.get_argument_replica_timeout() is None:
raise RequiredArgumentMissingError('Usage error: --replica-timeout is required')

if self.get_argument_replica_retry_limit() is None:
raise RequiredArgumentMissingError('Usage error: --replica-retry-limit is required')

if self.get_argument_managed_env() is None:
raise RequiredArgumentMissingError('Usage error: --environment is required if not using --yaml')
Expand Down Expand Up @@ -278,7 +273,7 @@ def construct_payload(self):
eventTriggerConfig_def = None
if self.get_argument_trigger_type() is not None and self.get_argument_trigger_type().lower() == "event":
scale_def = None
if self.get_argument_min_executions() is not None or self.get_argument_max_executions() is not None or self.get_argument_polling_interval() is not None:
if self.get_argument_min_executions() or self.get_argument_max_executions() or self.get_argument_polling_interval():
scale_def = JobScaleModel
scale_def["pollingInterval"] = self.get_argument_polling_interval()
scale_def["minExecutions"] = self.get_argument_min_executions()
Expand Down Expand Up @@ -499,6 +494,12 @@ def construct_payload(self):
super().construct_payload()
self.set_up_extended_location()

def validate_arguments(self):
super().validate_arguments()
if self.get_argument_yaml() is None:
if self.get_argument_trigger_type() is None:
raise RequiredArgumentMissingError('Usage error: --trigger-type is required')

def set_up_extended_location(self):
if self.get_argument_environment_type() == CONNECTED_ENVIRONMENT_TYPE:
if not self.containerappjob_def.get('extendedLocation'):
Expand Down
14 changes: 7 additions & 7 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,10 @@ def create_containerappsjob(cmd,
container_name=None,
managed_env=None,
trigger_type=None,
replica_timeout=None,
replica_retry_limit=None,
replica_completion_count=None,
parallelism=None,
replica_timeout=1800,
replica_retry_limit=0,
replica_completion_count=1,
parallelism=1,
cron_expression=None,
secrets=None,
env_vars=None,
Expand All @@ -825,9 +825,9 @@ def create_containerappsjob(cmd,
scale_rule_name=None,
scale_rule_type=None,
scale_rule_auth=None,
polling_interval=None,
min_executions=None,
max_executions=None,
polling_interval=30,
min_executions=0,
max_executions=10,
tags=None,
no_wait=False,
system_assigned=False,
Expand Down
Loading

0 comments on commit edfe5b6

Please sign in to comment.