@@ -95,14 +95,14 @@ func (r *QuestDBSnapshotScheduleReconciler) Reconcile(ctx context.Context, req c
9595 }
9696
9797 // Check if we are due for a snapshot
98- nextSnapshotTime , err := r .getNextSnapshotTime (sched )
98+ lastSnapshotTime , err := r .getLastSnapshotTime (sched )
9999 if err != nil {
100100 return ctrl.Result {}, err
101101 }
102102
103- if nextSnapshotTime .Compare (r .TimeSource .Now ()) <= 0 {
103+ if lastSnapshotTime .Compare (r .TimeSource .Now ()) <= 0 {
104104 // Update the next snapshot time
105- sched .Status .NextSnapshot = metav1 .NewTime (nextSnapshotTime )
105+ sched .Status .LastSnapshot = metav1 .NewTime (lastSnapshotTime )
106106 if err = r .Status ().Update (ctx , sched ); err != nil {
107107 // If this update fails, re-reconcile immediately
108108 return ctrl.Result {}, err
@@ -134,7 +134,7 @@ func (r *QuestDBSnapshotScheduleReconciler) Reconcile(ctx context.Context, req c
134134 // Garbage collect old successful snapshots
135135 err = r .garbageCollect (ctx , childSnapshots , sched .Spec .Retention )
136136
137- return ctrl.Result {RequeueAfter : nextSnapshotTime .Sub (r .TimeSource .Now ())}, err
137+ return ctrl.Result {RequeueAfter : lastSnapshotTime .Sub (r .TimeSource .Now ())}, err
138138}
139139
140140// SetupWithManager sets up the controller with the Manager.
@@ -217,14 +217,14 @@ func (r *QuestDBSnapshotScheduleReconciler) garbageCollect(ctx context.Context,
217217
218218}
219219
220- func (r * QuestDBSnapshotScheduleReconciler ) getNextSnapshotTime (sched * crdv1beta1.QuestDBSnapshotSchedule ) (time.Time , error ) {
220+ func (r * QuestDBSnapshotScheduleReconciler ) getLastSnapshotTime (sched * crdv1beta1.QuestDBSnapshotSchedule ) (time.Time , error ) {
221221 parser := cron .NewParser (cron .Minute | cron .Hour | cron .Dom | cron .Month | cron .Dow )
222222 crontab , err := parser .Parse (sched .Spec .Schedule )
223223 if err != nil {
224224 return time.Time {}, err
225225 }
226226
227- lastTime := sched .Status .NextSnapshot .Time
227+ lastTime := sched .Status .LastSnapshot .Time
228228 if lastTime .IsZero () {
229229 lastTime = sched .CreationTimestamp .Time
230230 }
0 commit comments