Merge pull request #3850 from ansible/container-groups-cleanup-adhoc

clean up pods for all k8s execution, not just playbook runs
This commit is contained in:
Ryan Petrello 2019-10-17 16:53:23 -04:00 committed by GitHub
commit 0bcd1db239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: