@@ -231,16 +231,17 @@ pub async fn reconcile(replica: Arc<PostgresPhysicalReplica>, ctx: Arc<Context>)
231231
232232 // Recompute next scheduled restore in case schedule changed while restore was in flight
233233 if let Some ( schedule) = & replica. spec . schedule
234- && let Some ( next) = compute_next_scheduled_restore ( schedule) {
235- update_replica_status_field (
236- client,
237- & namespace,
238- & name,
239- "nextScheduledRestore" ,
240- & next. to_rfc3339 ( ) ,
241- )
242- . await ?;
243- }
234+ && let Some ( next) = compute_next_scheduled_restore ( schedule)
235+ {
236+ update_replica_status_field (
237+ client,
238+ & namespace,
239+ & name,
240+ "nextScheduledRestore" ,
241+ & next. to_rfc3339 ( ) ,
242+ )
243+ . await ?;
244+ }
244245
245246 return Ok ( Action :: requeue ( Duration :: from_secs ( 10 ) ) ) ;
246247 }
@@ -413,16 +414,17 @@ pub async fn reconcile(replica: Arc<PostgresPhysicalReplica>, ctx: Arc<Context>)
413414 // Whether a restore was created or skipped, advance nextScheduledRestore
414415 // so we don't re-trigger on the next reconciliation.
415416 if let Some ( schedule) = & replica. spec . schedule
416- && let Some ( next) = compute_next_scheduled_restore ( schedule) {
417- update_replica_status_field (
418- client,
419- & namespace,
420- & name,
421- "nextScheduledRestore" ,
422- & next. to_rfc3339 ( ) ,
423- )
424- . await ?;
425- }
417+ && let Some ( next) = compute_next_scheduled_restore ( schedule)
418+ {
419+ update_replica_status_field (
420+ client,
421+ & namespace,
422+ & name,
423+ "nextScheduledRestore" ,
424+ & next. to_rfc3339 ( ) ,
425+ )
426+ . await ?;
427+ }
426428 }
427429
428430 // Update phase based on current state
@@ -692,14 +694,15 @@ fn should_trigger_scheduled_restore(replica: &PostgresPhysicalReplica) -> bool {
692694
693695 // Check minimumTTL
694696 if let Some ( last_completed) = status. and_then ( |s| s. last_restore_completed_at . as_ref ( ) )
695- && let Ok ( last_completed) = last_completed. parse :: < chrono:: DateTime < Utc > > ( ) {
696- let minimum_ttl =
697- parse_duration ( & replica . spec . minimum_ttl ) . unwrap_or ( Duration :: from_secs ( 6 * 3600 ) ) ;
698- let elapsed = Utc :: now ( ) . signed_duration_since ( last_completed ) ;
699- if elapsed. to_std ( ) . unwrap_or_default ( ) < minimum_ttl {
700- return false ;
701- }
697+ && let Ok ( last_completed) = last_completed. parse :: < chrono:: DateTime < Utc > > ( )
698+ {
699+ let minimum_ttl =
700+ parse_duration ( & replica . spec . minimum_ttl ) . unwrap_or ( Duration :: from_secs ( 6 * 3600 ) ) ;
701+ let elapsed = Utc :: now ( ) . signed_duration_since ( last_completed ) ;
702+ if elapsed . to_std ( ) . unwrap_or_default ( ) < minimum_ttl {
703+ return false ;
702704 }
705+ }
703706
704707 // Check cron schedule
705708 let Ok ( cron_schedule) = schedule. parse :: < cron:: Schedule > ( ) else {
@@ -715,20 +718,22 @@ fn should_trigger_scheduled_restore(replica: &PostgresPhysicalReplica) -> bool {
715718 let now = Utc :: now ( ) ;
716719
717720 if let Some ( next_scheduled) = status. and_then ( |s| s. next_scheduled_restore . as_ref ( ) )
718- && let Ok ( next) = next_scheduled. parse :: < chrono:: DateTime < Utc > > ( ) {
719- // Add jitter to the scheduled time
720- let trigger_at = next + chrono:: Duration :: from_std ( jitter) . unwrap_or_default ( ) ;
721- return now >= trigger_at;
722- }
721+ && let Ok ( next) = next_scheduled. parse :: < chrono:: DateTime < Utc > > ( )
722+ {
723+ // Add jitter to the scheduled time
724+ let trigger_at = next + chrono:: Duration :: from_std ( jitter) . unwrap_or_default ( ) ;
725+ return now >= trigger_at;
726+ }
723727
724728 // Initial seed: nextScheduledRestore not yet set (first reconciliation or field was cleared).
725729 // Fall back to checking whether a cron occurrence falls within a 24h lookback window.
726730 let jittered_now = now - chrono:: Duration :: from_std ( jitter) . unwrap_or_default ( ) ;
727- for prev in cron_schedule. after ( & ( jittered_now - chrono:: Duration :: hours ( 24 ) ) ) {
728- if prev <= now {
729- return true ;
730- }
731- break ;
731+ if let Some ( prev) = cron_schedule
732+ . after ( & ( jittered_now - chrono:: Duration :: hours ( 24 ) ) )
733+ . next ( )
734+ && prev <= now
735+ {
736+ return true ;
732737 }
733738
734739 false
@@ -1032,6 +1037,10 @@ async fn update_restore_activated_at(
10321037 Ok ( ( ) )
10331038}
10341039
1040+ #[ expect(
1041+ clippy:: too_many_arguments,
1042+ reason = "notification dispatch needs all these context params"
1043+ ) ]
10351044async fn send_restore_notifications (
10361045 client : & Client ,
10371046 http_client : & reqwest:: Client ,
0 commit comments