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
This commit is contained in:
Phil Sphicas 2019-11-14 07:54:06 -08:00 committed by Phil Sphicas
parent 430586927c
commit 6a9b3bf9c9
1 changed files with 3 additions and 6 deletions

View File

@ -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()