@@ -69,6 +69,7 @@ func (r *QuestDBSnapshotReconciler) Reconcile(ctx context.Context, req ctrl.Requ
6969 }
7070
7171 // Set default value for job backoff limit in case it is not set
72+ // This should not happen because it is set in the defaulting webhook
7273 if snap .Spec .JobBackoffLimit == 0 {
7374 snap .Spec .JobBackoffLimit = crdv1beta1 .JobBackoffLimitDefault
7475 err = r .Update (ctx , snap )
@@ -217,7 +218,7 @@ func (r *QuestDBSnapshotReconciler) buildVolumeSnapshot(snap *crdv1beta1.QuestDB
217218}
218219
219220func (r * QuestDBSnapshotReconciler ) handlePhaseEmpty (ctx context.Context , snap * crdv1beta1.QuestDBSnapshot ) (ctrl.Result , error ) {
220- // Check that the QuestDB exists
221+ // Check that the QuestDB exists before starting the snapshot process
221222 qdb := & crdv1beta1.QuestDB {}
222223 namespacedName := types.NamespacedName {Namespace : snap .Namespace , Name : snap .Spec .QuestDBName }
223224 err := r .Get (ctx , namespacedName , qdb )
@@ -258,6 +259,9 @@ func (r *QuestDBSnapshotReconciler) handlePhasePending(ctx context.Context, snap
258259 }
259260 }
260261
262+ // todo: if no volume snapshot class is specified, check that there is a default one in the cluster
263+ // if a default is not found, then fail the snapshot
264+
261265 // Create the pre-snapshot job
262266 job , err := r .buildPreSnapshotJob (ctx , snap )
263267 if err != nil {
@@ -388,20 +392,27 @@ func (r *QuestDBSnapshotReconciler) handlePhaseFinalizing(ctx context.Context, s
388392}
389393
390394func (r * QuestDBSnapshotReconciler ) handlePhaseFailed (ctx context.Context , snap * crdv1beta1.QuestDBSnapshot ) (ctrl.Result , error ) {
391- var err error
395+ var (
396+ err error
397+ updated bool
398+ )
399+
392400 // Remove the SnapshotCompleteFinalizer
393- if controllerutil .ContainsFinalizer (snap , crdv1beta1 .SnapshotCompleteFinalizer ) {
394- controllerutil . RemoveFinalizer ( snap , crdv1beta1 . SnapshotCompleteFinalizer )
401+ updated = controllerutil .RemoveFinalizer (snap , crdv1beta1 .SnapshotCompleteFinalizer )
402+ if updated {
395403 err = r .Update (ctx , snap )
396404 }
397405 return ctrl.Result {}, err
398406}
399407
400408func (r * QuestDBSnapshotReconciler ) handlePhaseSucceeded (ctx context.Context , snap * crdv1beta1.QuestDBSnapshot ) (ctrl.Result , error ) {
401- var err error
409+ var (
410+ err error
411+ updated bool
412+ )
402413 // Remove the SnapshotCompleteFinalizer
403- if controllerutil .ContainsFinalizer (snap , crdv1beta1 .SnapshotCompleteFinalizer ) {
404- controllerutil . RemoveFinalizer ( snap , crdv1beta1 . SnapshotCompleteFinalizer )
414+ updated = controllerutil .RemoveFinalizer (snap , crdv1beta1 .SnapshotCompleteFinalizer )
415+ if updated {
405416 err = r .Update (ctx , snap )
406417 if err != nil {
407418 return ctrl.Result {}, err
0 commit comments