Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
use foreground propagation policy when replacing objects
Browse files Browse the repository at this point in the history
  • Loading branch information
imsky committed Mar 16, 2018
1 parent e334732 commit 2013b3f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
batchv2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
)

//todo: filter out Jobs that are children of CronJobs
func pairObjectsByCriteria(srcObjects []runtime.Object, dstObjects []runtime.Object, criteria PairCriteria) []ObjectPair {
pairs := make([]ObjectPair, 0, len(srcObjects))

Expand Down Expand Up @@ -195,6 +196,7 @@ func executePlan(plan []Step, clientset *kubernetes.Clientset, execute bool) {
dst := *step.pair.dst
srcMetadata, _ := getObjectMetadata(src)
dstMetadata, _ := getObjectMetadata(dst)
propagationPolicy := metav1.DeletePropagationForeground
//todo: use object metadata instead of type switch
switch srcType := src.(type) {
case *batchv1.Job:
Expand All @@ -207,8 +209,7 @@ func executePlan(plan []Step, clientset *kubernetes.Clientset, execute bool) {
break
}

//todo: set propagation policy?
err := clientset.BatchV1().Jobs(dstMetadata.GetNamespace()).Delete(dstMetadata.GetName(), nil)
err := clientset.BatchV1().Jobs(dstMetadata.GetNamespace()).Delete(dstMetadata.GetName(), &metav1.DeleteOptions{PropagationPolicy: &propagationPolicy})

if err != nil {
panic(err)
Expand All @@ -227,9 +228,9 @@ func executePlan(plan []Step, clientset *kubernetes.Clientset, execute bool) {
if !execute {
break
}
//todo: set propagation policy?

//todo: delete current CronJob child Jobs
err := clientset.BatchV2alpha1().CronJobs(dstMetadata.GetNamespace()).Delete(dstMetadata.GetName(), nil)
err := clientset.BatchV2alpha1().CronJobs(dstMetadata.GetNamespace()).Delete(dstMetadata.GetName(), &metav1.DeleteOptions{PropagationPolicy: &propagationPolicy})
if err != nil {
panic(err)
}
Expand All @@ -251,8 +252,8 @@ func executePlan(plan []Step, clientset *kubernetes.Clientset, execute bool) {
if !execute {
break
}
//todo: set propagation policy?
err := clientset.BatchV1().Jobs(dstMetadata.GetNamespace()).Delete(dstMetadata.GetName(), nil)

err := clientset.BatchV1().Jobs(dstMetadata.GetNamespace()).Delete(dstMetadata.GetName(), &metav1.DeleteOptions{PropagationPolicy: &propagationPolicy})

if err != nil {
panic(err)
Expand Down

0 comments on commit 2013b3f

Please sign in to comment.