Skip to content

Commit 62cefce

Browse files
committed
Fix code errors in finalizer example
1 parent da65999 commit 62cefce

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docs/book/src/cronjob-tutorial/testdata/finalizer_example.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
4141
ctx := context.Background()
4242
log := r.Log.WithValues("cronjob", req.NamespacedName)
4343

44-
var cronJob batch.CronJob
45-
if err := r.Get(ctx, req.NamespacedName, &cronJob); err != nil {
44+
var cronJob *batchv1.CronJob
45+
if err := r.Get(ctx, req.NamespacedName, cronJob); err != nil {
4646
log.Error(err, "unable to fetch CronJob")
4747
// we'll ignore not-found errors, since they can't be fixed by an immediate
4848
// requeue (we'll need to wait for a new notification), and we can get them
@@ -81,10 +81,13 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
8181
}
8282
}
8383

84-
return ctrl.Result{}, err
84+
// Stop reconciliation as the item is being deleted
85+
return ctrl.Result{}, nil
8586
}
8687

87-
// rest of the reconciler code
88+
// Your reconcile logic
89+
90+
return ctrl.Result{}, nil
8891
}
8992

9093
func (r *Reconciler) deleteExternalResources(cronJob *batch.CronJob) error {

0 commit comments

Comments
 (0)