diff --git a/awx/main/scheduler/kubernetes.py b/awx/main/scheduler/kubernetes.py index 68a95e2fc2..862cfd3f04 100644 --- a/awx/main/scheduler/kubernetes.py +++ b/awx/main/scheduler/kubernetes.py @@ -173,7 +173,7 @@ def generate_tmp_kube_config(credential, namespace): "current-context": host_input } - if credential.get_input('verify_ssl'): + if credential.get_input('verify_ssl') and 'ssl_ca_cert' in credential.inputs: config["clusters"][0]["cluster"]["certificate-authority-data"] = b64encode( credential.get_input('ssl_ca_cert').encode() # encode to bytes ).decode() # decode the base64 data into a str diff --git a/awx/main/scheduler/task_manager.py b/awx/main/scheduler/task_manager.py index e7ffb21487..32e8a7defb 100644 --- a/awx/main/scheduler/task_manager.py +++ b/awx/main/scheduler/task_manager.py @@ -258,19 +258,24 @@ class TaskManager(): for group in InstanceGroup.objects.all(): if group.is_containerized or group.controller_id: continue - match = group.find_largest_idle_instance() + match = group.fit_task_to_most_remaining_capacity_instance(task) if match: break task.instance_group = rampart_group - if task.supports_isolation(): - task.controller_node = match.hostname + if match is None: + logger.warn( + 'No available capacity to run containerized <{}>.'.format(task.log_format) + ) else: - # project updates and inventory updates don't *actually* run in pods, - # so just pick *any* non-isolated, non-containerized host and use it - # as the execution node - task.execution_node = match.hostname - logger.debug('Submitting containerized {} to queue {}.'.format( - task.log_format, task.execution_node)) + if task.supports_isolation(): + task.controller_node = match.hostname + else: + # project updates and inventory updates don't *actually* run in pods, + # so just pick *any* non-isolated, non-containerized host and use it + # as the execution node + task.execution_node = match.hostname + logger.debug('Submitting containerized {} to queue {}.'.format( + task.log_format, task.execution_node)) else: task.instance_group = rampart_group if instance is not None: