From 570ffad52b8d151711b4ea27d1734a55832cfdb9 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 17 Oct 2019 15:29:44 -0400 Subject: [PATCH] clean up pods for all k8s execution, not just playbook runs see: https://github.com/ansible/awx/issues/4908 --- awx/main/tasks.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 5a7fea3bf3..10aac79dd9 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1094,6 +1094,13 @@ class BaseTask(object): if os.path.isdir(job_profiling_dir): shutil.copytree(job_profiling_dir, os.path.join(awx_profiling_dir, str(instance.pk))) + if instance.is_containerized: + from awx.main.scheduler.kubernetes import PodManager # prevent circular import + pm = PodManager(instance) + logger.debug(f"Deleting pod {pm.pod_name}") + pm.delete() + + def event_handler(self, event_data): # # ⚠️ D-D-D-DANGER ZONE ⚠️ @@ -1841,13 +1848,6 @@ class RunJob(BaseTask): if isolated_manager_instance and not job.is_containerized: isolated_manager_instance.cleanup() - if job.is_containerized: - from awx.main.scheduler.kubernetes import PodManager # prevent circular import - pm = PodManager(job) - logger.debug(f"Deleting pod {pm.pod_name}") - pm.delete() - - try: inventory = job.inventory except Inventory.DoesNotExist: