Skip to content

Commit 217b0c3

Browse files
committed
requeue requests
1 parent d01e8ff commit 217b0c3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

controllers/dataprotection/restore_controller.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package dataprotection
2121

2222
import (
2323
"context"
24+
"errors"
2425
"fmt"
2526
"reflect"
2627
"time"
@@ -317,8 +318,13 @@ func (r *RestoreReconciler) handleRunningPhase(reqCtx intctrlutil.RequestCtx, re
317318
err = r.Client.Status().Patch(reqCtx.Ctx, restoreMgr.Restore, client.MergeFrom(restoreMgr.OriginalRestore))
318319
}
319320
if err != nil {
320-
r.Recorder.Event(restore, corev1.EventTypeWarning, corev1.EventTypeWarning, err.Error())
321-
return intctrlutil.RequeueWithError(err, reqCtx.Log, "")
321+
if errors.Is(err, ErrWaitClusterRunning) {
322+
r.Recorder.Event(restore, corev1.EventTypeWarning, dprestore.ReasonWaitForClusterRunning, err.Error())
323+
return intctrlutil.Requeue(reqCtx.Log, err.Error())
324+
} else {
325+
r.Recorder.Event(restore, corev1.EventTypeWarning, corev1.EventTypeWarning, err.Error())
326+
return intctrlutil.RequeueWithError(err, reqCtx.Log, "")
327+
}
322328
}
323329
return intctrlutil.Reconciled()
324330
}
@@ -436,6 +442,8 @@ func (r *RestoreReconciler) postReady(reqCtx intctrlutil.RequestCtx, restoreMgr
436442
return true, nil
437443
}
438444

445+
var ErrWaitClusterRunning = errors.New("wait for cluster entering running phase")
446+
439447
func (r *RestoreReconciler) handleBackupActionSet(reqCtx intctrlutil.RequestCtx,
440448
restoreMgr *dprestore.RestoreManager,
441449
backupSet dprestore.BackupActionSet,
@@ -484,8 +492,7 @@ func (r *RestoreReconciler) handleBackupActionSet(reqCtx intctrlutil.RequestCtx,
484492
return false, err
485493
}
486494
if cluster.Status.Phase != kbappsv1.RunningClusterPhase {
487-
reqCtx.Recorder.Event(restoreMgr.Restore, corev1.EventTypeWarning, dprestore.ReasonWaitForClusterRunning, "wait for cluster entering running phase")
488-
return false, nil
495+
return false, ErrWaitClusterRunning
489496
}
490497
return true, nil
491498
}

controllers/dataprotection/suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ var fakeClock *testclocks.FakeClock
6969

7070
func init() {
7171
viper.AutomaticEnv()
72+
// viper.Set("ENABLE_DEBUG_LOG", "true")
7273
}
7374

7475
func TestAPIs(t *testing.T) {

0 commit comments

Comments
 (0)