@@ -38,6 +38,10 @@ func GetWALWatcher(cr *pgv2.PerconaPGCluster) (string, WALWatcher) {
3838func WatchCommitTimestamps (ctx context.Context , cli client.Client , eventChan chan event.GenericEvent , stopChan chan event.DeleteEvent , cr * pgv2.PerconaPGCluster ) {
3939 log := logging .FromContext (ctx ).WithName ("WALWatcher" )
4040
41+ if ! cr .Spec .Backups .IsEnabled () {
42+ return
43+ }
44+
4145 log .Info ("Watching commit timestamps" )
4246
4347 execCli , err := clientcmd .NewClient ()
@@ -52,15 +56,18 @@ func WatchCommitTimestamps(ctx context.Context, cli client.Client, eventChan cha
5256 for {
5357 select {
5458 case <- ticker .C :
55- log .V (1 ).Info ("Running WAL watcher" )
56-
5759 localCr := cr .DeepCopy ()
5860 err := cli .Get (ctx , client .ObjectKeyFromObject (cr ), localCr )
5961 if err != nil {
6062 log .Error (err , "get cluster" )
6163 return
6264 }
6365
66+ if ! localCr .Spec .Backups .IsEnabled () {
67+ continue
68+ }
69+ log .V (1 ).Info ("Running WAL watcher" )
70+
6471 latestBackup , err := getLatestBackup (ctx , cli , localCr )
6572 if err != nil {
6673 if ! errors .Is (err , errRunningBackup ) && ! errors .Is (err , errNoBackups ) {
@@ -69,7 +76,6 @@ func WatchCommitTimestamps(ctx context.Context, cli client.Client, eventChan cha
6976
7077 continue
7178 }
72-
7379 ts , err := GetLatestCommitTimestamp (ctx , cli , execCli , localCr , latestBackup )
7480 if err != nil {
7581 switch {
0 commit comments