Skip to content

Commit

Permalink
address child pods are preserved by default when jobs are deleted war…
Browse files Browse the repository at this point in the history
…ning
  • Loading branch information
freeznet committed Oct 24, 2023
1 parent a1ee414 commit 5f67573
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions controllers/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package controllers
import (
"context"

"sigs.k8s.io/controller-runtime/pkg/client"

autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"

"github.com/streamnative/function-mesh/api/compute/v1alpha1"
Expand Down Expand Up @@ -334,6 +336,10 @@ func (r *FunctionReconciler) ApplyFunctionVPA(ctx context.Context, function *v1a
}

func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, function *v1alpha1.Function) error {
backgroundDeletion := metav1.DeletePropagationBackground
var deleteOptions client.DeleteOption = &client.DeleteOptions{
PropagationPolicy: &backgroundDeletion,
}
if !spec.NeedCleanup(function) {
desiredJob := spec.MakeFunctionCleanUpJob(function)
if err := r.Delete(ctx, desiredJob); err != nil {
Expand Down Expand Up @@ -380,7 +386,7 @@ func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, functi
}
} else {
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, deleteOptions); err != nil {
return err
}
}
Expand All @@ -395,10 +401,9 @@ func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, functi

desiredJob := spec.MakeFunctionCleanUpJob(function)
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, deleteOptions); err != nil {
return err
}

}
}
return nil
Expand Down

0 comments on commit 5f67573

Please sign in to comment.