From 6a9b3bf9c9ffb80f244db242b3760f69fca9729f Mon Sep 17 00:00:00 2001 From: Phil Sphicas Date: Thu, 14 Nov 2019 07:54:06 -0800 Subject: [PATCH] Fix: Use Foreground deletion Armada intends to use `propagationPolicy: Foreground` when deleting resources. However, the empty V1DeleteOptions object in the body of the delete API call takes priority over the propogation_policy specified as a query param, resulting in the per-resouce default. For Job and CronJob resources, the default is Orphan, and for others it is Background. This change includes the desired propogation_policy in V1DeleteOptions. Reference: https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#setting-the-cascading-deletion-policy Change-Id: Iffee12b426ba1e7741eb5bd687ca1b2c11cb071d --- armada/handlers/k8s.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/armada/handlers/k8s.py b/armada/handlers/k8s.py index 06c68b6b..f65a6316 100644 --- a/armada/handlers/k8s.py +++ b/armada/handlers/k8s.py @@ -153,18 +153,15 @@ class K8s(object): LOG.debug( 'Watching to delete %s %s, Wait timeout=%s', object_type_description, name, timeout) - body = client.V1DeleteOptions() + body = client.V1DeleteOptions( + propagation_policy=propagation_policy) w = watch.Watch() issue_delete = True found_events = False for event in w.stream(list_func, namespace=namespace, timeout_seconds=timeout): if issue_delete: - delete_func( - name=name, - namespace=namespace, - body=body, - propagation_policy=propagation_policy) + delete_func(name=name, namespace=namespace, body=body) issue_delete = False event_type = event['type'].upper()