From bf871bd427e5cddceb8dd4c82aba9208f802bac3 Mon Sep 17 00:00:00 2001 From: Elijah DeLee Date: Tue, 8 Nov 2022 09:52:59 -0500 Subject: [PATCH] settings for max forks/job on default job queue This will allow users of the operator to set these settings so from the start when the operator creates the default execution queue they can control the max_forks and max_concurrent_jobs on the default container group. --- awx/main/management/commands/provision_instance.py | 9 ++++++++- awx/main/management/commands/register_queue.py | 14 +++++++++++++- awx/settings/defaults.py | 7 +++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/awx/main/management/commands/provision_instance.py b/awx/main/management/commands/provision_instance.py index 75c297e8f0..b996db4125 100644 --- a/awx/main/management/commands/provision_instance.py +++ b/awx/main/management/commands/provision_instance.py @@ -38,7 +38,14 @@ class Command(BaseCommand): (changed, instance) = Instance.objects.register(ip_address=os.environ.get('MY_POD_IP'), node_type='control', uuid=settings.SYSTEM_UUID) RegisterQueue(settings.DEFAULT_CONTROL_PLANE_QUEUE_NAME, 100, 0, [], is_container_group=False).register() RegisterQueue( - settings.DEFAULT_EXECUTION_QUEUE_NAME, 100, 0, [], is_container_group=True, pod_spec_override=settings.DEFAULT_EXECUTION_QUEUE_POD_SPEC_OVERRIDE + settings.DEFAULT_EXECUTION_QUEUE_NAME, + 100, + 0, + [], + is_container_group=True, + pod_spec_override=settings.DEFAULT_EXECUTION_QUEUE_POD_SPEC_OVERRIDE, + max_forks=settings.DEFAULT_EXECUTION_QUEUE_MAX_FORKS, + max_concurrent_jobs=settings.DEFAULT_EXECUTION_QUEUE_MAX_CONCURRENT_JOBS, ).register() else: (changed, instance) = Instance.objects.register(hostname=hostname, node_type=node_type, uuid=uuid) diff --git a/awx/main/management/commands/register_queue.py b/awx/main/management/commands/register_queue.py index 3268dc0ebc..36b7d17b1b 100644 --- a/awx/main/management/commands/register_queue.py +++ b/awx/main/management/commands/register_queue.py @@ -17,7 +17,9 @@ class InstanceNotFound(Exception): class RegisterQueue: - def __init__(self, queuename, instance_percent, inst_min, hostname_list, is_container_group=None, pod_spec_override=None): + def __init__( + self, queuename, instance_percent, inst_min, hostname_list, is_container_group=None, pod_spec_override=None, max_forks=None, max_concurrent_jobs=None + ): self.instance_not_found_err = None self.queuename = queuename self.instance_percent = instance_percent @@ -25,6 +27,8 @@ class RegisterQueue: self.hostname_list = hostname_list self.is_container_group = is_container_group self.pod_spec_override = pod_spec_override + self.max_forks = max_forks + self.max_concurrent_jobs = max_concurrent_jobs def get_create_update_instance_group(self): created = False @@ -45,6 +49,14 @@ class RegisterQueue: ig.pod_spec_override = self.pod_spec_override changed = True + if self.max_forks and (ig.max_forks != self.max_forks): + ig.max_forks = self.max_forks + changed = True + + if self.max_concurrent_jobs and (ig.max_concurrent_jobs != self.max_concurrent_jobs): + ig.max_concurrent_jobs = self.max_concurrent_jobs + changed = True + if changed: ig.save() diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index e365c2a48f..577bee627f 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -983,6 +983,13 @@ DJANGO_GUID = {'GUID_HEADER_NAME': 'X-API-Request-Id'} DEFAULT_EXECUTION_QUEUE_NAME = 'default' # pod spec used when the default execution queue is a container group, e.g. when deploying on k8s/ocp with the operator DEFAULT_EXECUTION_QUEUE_POD_SPEC_OVERRIDE = '' +# Max number of concurrently consumed forks for the default execution queue +# Zero means no limit +DEFAULT_EXECUTION_QUEUE_MAX_FORKS = 0 +# Max number of concurrently running jobs for the default execution queue +# Zero means no limit +DEFAULT_EXECUTION_QUEUE_MAX_CONCURRENT_JOBS = 0 + # Name of the default controlplane queue DEFAULT_CONTROL_PLANE_QUEUE_NAME = 'controlplane'