Skip to content

Commit 73bb7c7

Browse files
authored
Merge pull request #1324 from percona/K8SPG-844-logs
K8SPG-874 early return when backups are disabled
2 parents 149544a + 5749c0f commit 73bb7c7

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

e2e-tests/functions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ deploy_operator() {
5555
fi
5656
yq eval '.spec.template.spec.containers[0].image = "'${IMAGE}'"' "${DEPLOY_DIR}/${cw_prefix}operator.yaml" \
5757
| yq eval '(.spec.template.spec.containers[] | select(.name=="operator") | .env[] | select(.name=="DISABLE_TELEMETRY") | .value) = "'${disable_telemetry}'"' - \
58+
| yq eval '(.spec.template.spec.containers[] | select(.name=="operator") | .env[] | select(.name=="LOG_LEVEL") | .value) = "DEBUG"' - \
5859
| kubectl -n "${OPERATOR_NS:-$NAMESPACE}" apply -f -
5960
}
6061

percona/controller/pgbackup/controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ func (r *PGBackupReconciler) Reconcile(ctx context.Context, request reconcile.Re
297297
if err != nil {
298298
return reconcile.Result{}, errors.Wrap(err, "failed to create exec client")
299299
}
300-
301300
latestRestorableTime, err := watcher.GetLatestCommitTimestamp(ctx, r.Client, execCli, pgCluster, pgBackup)
302301
if err == nil {
303302
log.Info("Got latest restorable timestamp", "timestamp", latestRestorableTime)

percona/controller/pgcluster/backup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func (r *PGClusterReconciler) reconcileBackups(ctx context.Context, cr *v2.Perco
3939
func (r *PGClusterReconciler) cleanupOutdatedBackups(ctx context.Context, cr *v2.PerconaPGCluster) error {
4040
log := logging.FromContext(ctx)
4141

42+
if !cr.Spec.Backups.IsEnabled() {
43+
return nil
44+
}
45+
4246
if cr.Status.State != v2.AppStateReady {
4347
return nil
4448
}

percona/controller/pgcluster/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,8 @@ func (r *PGClusterReconciler) reconcileExternalWatchers(ctx context.Context, cr
978978
}
979979

980980
func (r *PGClusterReconciler) startExternalWatchers(ctx context.Context, cr *v2.PerconaPGCluster) error {
981+
log := logging.FromContext(ctx)
982+
981983
if !cr.Spec.Backups.IsEnabled() {
982984
return nil
983985
}
@@ -986,8 +988,6 @@ func (r *PGClusterReconciler) startExternalWatchers(ctx context.Context, cr *v2.
986988
return nil
987989
}
988990

989-
log := logging.FromContext(ctx)
990-
991991
watcherName, watcherFunc := watcher.GetWALWatcher(cr)
992992
if r.Watchers.IsExist(watcherName) {
993993
return nil

percona/watcher/wal.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func GetWALWatcher(cr *pgv2.PerconaPGCluster) (string, WALWatcher) {
3838
func 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

Comments
 (0)