Skip to content

Commit 5f67573

Browse files
committed
address child pods are preserved by default when jobs are deleted warning
1 parent a1ee414 commit 5f67573

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

controllers/function.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package controllers
2020
import (
2121
"context"
2222

23+
"sigs.k8s.io/controller-runtime/pkg/client"
24+
2325
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
2426

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

336338
func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, function *v1alpha1.Function) error {
339+
backgroundDeletion := metav1.DeletePropagationBackground
340+
var deleteOptions client.DeleteOption = &client.DeleteOptions{
341+
PropagationPolicy: &backgroundDeletion,
342+
}
337343
if !spec.NeedCleanup(function) {
338344
desiredJob := spec.MakeFunctionCleanUpJob(function)
339345
if err := r.Delete(ctx, desiredJob); err != nil {
@@ -380,7 +386,7 @@ func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, functi
380386
}
381387
} else {
382388
// delete the cleanup job
383-
if err := r.Delete(ctx, desiredJob); err != nil {
389+
if err := r.Delete(ctx, desiredJob, deleteOptions); err != nil {
384390
return err
385391
}
386392
}
@@ -395,10 +401,9 @@ func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, functi
395401

396402
desiredJob := spec.MakeFunctionCleanUpJob(function)
397403
// delete the cleanup job
398-
if err := r.Delete(ctx, desiredJob); err != nil {
404+
if err := r.Delete(ctx, desiredJob, deleteOptions); err != nil {
399405
return err
400406
}
401-
402407
}
403408
}
404409
return nil

0 commit comments

Comments
 (0)