@@ -274,6 +274,79 @@ func (r *Reconciler) waitForStatefulSetToScale(
274274 return Continue , ctrl.Result {Requeue : false }, nil
275275}
276276
277+ func (r * Reconciler ) handlePauseResume (
278+ ctx context.Context ,
279+ databaseNodeSet * resources.DatabaseNodeSetResource ,
280+ ) (bool , ctrl.Result , error ) {
281+ r .Log .Info ("running step handlePauseResume" )
282+
283+ if databaseNodeSet .Status .State == DatabaseNodeSetProvisioning {
284+ if databaseNodeSet .Spec .Pause {
285+ meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
286+ Type : NodeSetPausedCondition ,
287+ Status : metav1 .ConditionTrue ,
288+ Reason : ReasonCompleted ,
289+ })
290+ databaseNodeSet .Status .State = DatabaseNodeSetPaused
291+ } else {
292+ meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
293+ Type : NodeSetReadyCondition ,
294+ Status : metav1 .ConditionTrue ,
295+ Reason : ReasonCompleted ,
296+ })
297+ databaseNodeSet .Status .State = DatabaseNodeSetReady
298+ }
299+ return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
300+ }
301+
302+ if databaseNodeSet .Status .State == DatabaseNodeSetReady && databaseNodeSet .Spec .Pause {
303+ r .Log .Info ("`pause: true` was noticed, moving DatabaseNodeSet to state `Paused`" )
304+ meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
305+ Type : NodeSetReadyCondition ,
306+ Status : metav1 .ConditionFalse ,
307+ Reason : ReasonNotRequired ,
308+ Message : "Transitioning to state Paused" ,
309+ })
310+ databaseNodeSet .Status .State = DatabaseNodeSetPaused
311+ return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
312+ }
313+
314+ if databaseNodeSet .Status .State == DatabaseNodeSetPaused && ! databaseNodeSet .Spec .Pause {
315+ r .Log .Info ("`pause: false` was noticed, moving DatabaseNodeSet to state `Ready`" )
316+ meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
317+ Type : NodeSetPausedCondition ,
318+ Status : metav1 .ConditionFalse ,
319+ Reason : ReasonNotRequired ,
320+ Message : "Transitioning to state Ready" ,
321+ })
322+ databaseNodeSet .Status .State = DatabaseNodeSetReady
323+ return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
324+ }
325+
326+ if databaseNodeSet .Spec .Pause {
327+ if ! meta .IsStatusConditionTrue (databaseNodeSet .Status .Conditions , NodeSetPausedCondition ) {
328+ meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
329+ Type : NodeSetPausedCondition ,
330+ Status : metav1 .ConditionTrue ,
331+ Reason : ReasonCompleted ,
332+ })
333+ return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
334+ }
335+ } else {
336+ if ! meta .IsStatusConditionTrue (databaseNodeSet .Status .Conditions , NodeSetReadyCondition ) {
337+ meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
338+ Type : NodeSetReadyCondition ,
339+ Status : metav1 .ConditionTrue ,
340+ Reason : ReasonCompleted ,
341+ })
342+ return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
343+ }
344+ }
345+
346+ r .Log .Info ("complete step handlePauseResume" )
347+ return Continue , ctrl.Result {}, nil
348+ }
349+
277350func (r * Reconciler ) updateStatus (
278351 ctx context.Context ,
279352 databaseNodeSet * resources.DatabaseNodeSetResource ,
@@ -348,76 +421,3 @@ func shouldIgnoreDatabaseNodeSetChange(databaseNodeSet *resources.DatabaseNodeSe
348421 return false
349422 }
350423}
351-
352- func (r * Reconciler ) handlePauseResume (
353- ctx context.Context ,
354- databaseNodeSet * resources.DatabaseNodeSetResource ,
355- ) (bool , ctrl.Result , error ) {
356- r .Log .Info ("running step handlePauseResume" )
357-
358- if databaseNodeSet .Status .State == DatabaseNodeSetProvisioning {
359- if databaseNodeSet .Spec .Pause {
360- meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
361- Type : NodeSetPausedCondition ,
362- Status : metav1 .ConditionTrue ,
363- Reason : ReasonCompleted ,
364- })
365- databaseNodeSet .Status .State = DatabaseNodeSetPaused
366- } else {
367- meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
368- Type : NodeSetReadyCondition ,
369- Status : metav1 .ConditionTrue ,
370- Reason : ReasonCompleted ,
371- })
372- databaseNodeSet .Status .State = DatabaseNodeSetReady
373- }
374- return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
375- }
376-
377- if databaseNodeSet .Status .State == DatabaseNodeSetReady && databaseNodeSet .Spec .Pause {
378- r .Log .Info ("`pause: true` was noticed, moving DatabaseNodeSet to state `Paused`" )
379- meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
380- Type : NodeSetReadyCondition ,
381- Status : metav1 .ConditionFalse ,
382- Reason : ReasonNotRequired ,
383- Message : "Transitioning to state Paused" ,
384- })
385- databaseNodeSet .Status .State = DatabaseNodeSetPaused
386- return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
387- }
388-
389- if databaseNodeSet .Status .State == DatabaseNodeSetPaused && ! databaseNodeSet .Spec .Pause {
390- r .Log .Info ("`pause: false` was noticed, moving DatabaseNodeSet to state `Ready`" )
391- meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
392- Type : NodeSetPausedCondition ,
393- Status : metav1 .ConditionFalse ,
394- Reason : ReasonNotRequired ,
395- Message : "Transitioning to state Ready" ,
396- })
397- databaseNodeSet .Status .State = DatabaseNodeSetReady
398- return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
399- }
400-
401- if databaseNodeSet .Spec .Pause {
402- if ! meta .IsStatusConditionTrue (databaseNodeSet .Status .Conditions , NodeSetPausedCondition ) {
403- meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
404- Type : NodeSetPausedCondition ,
405- Status : metav1 .ConditionTrue ,
406- Reason : ReasonCompleted ,
407- })
408- return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
409- }
410- } else {
411- if ! meta .IsStatusConditionTrue (databaseNodeSet .Status .Conditions , NodeSetReadyCondition ) {
412- meta .SetStatusCondition (& databaseNodeSet .Status .Conditions , metav1.Condition {
413- Type : NodeSetReadyCondition ,
414- Status : metav1 .ConditionTrue ,
415- Reason : ReasonCompleted ,
416- })
417- return r .updateStatus (ctx , databaseNodeSet , StatusUpdateRequeueDelay )
418- }
419- }
420-
421- r .Log .Info ("complete step handlePauseResume" )
422- return Continue , ctrl.Result {}, nil
423- }
0 commit comments