Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ deploy_operator() {
fi
yq eval '.spec.template.spec.containers[0].image = "'${IMAGE}'"' "${DEPLOY_DIR}/${cw_prefix}operator.yaml" \
| yq eval '(.spec.template.spec.containers[] | select(.name=="operator") | .env[] | select(.name=="DISABLE_TELEMETRY") | .value) = "'${disable_telemetry}'"' - \
| yq eval '(.spec.template.spec.containers[] | select(.name=="operator") | .env[] | select(.name=="LOG_LEVEL") | .value) = "DEBUG"' - \
| kubectl -n "${OPERATOR_NS:-$NAMESPACE}" apply -f -
}

Expand Down
1 change: 0 additions & 1 deletion percona/controller/pgbackup/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ func (r *PGBackupReconciler) Reconcile(ctx context.Context, request reconcile.Re
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to create exec client")
}

latestRestorableTime, err := watcher.GetLatestCommitTimestamp(ctx, r.Client, execCli, pgCluster, pgBackup)
if err == nil {
log.Info("Got latest restorable timestamp", "timestamp", latestRestorableTime)
Expand Down
4 changes: 4 additions & 0 deletions percona/controller/pgcluster/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func (r *PGClusterReconciler) reconcileBackups(ctx context.Context, cr *v2.Perco
func (r *PGClusterReconciler) cleanupOutdatedBackups(ctx context.Context, cr *v2.PerconaPGCluster) error {
log := logging.FromContext(ctx)

if !cr.Spec.Backups.IsEnabled() {
return nil
}

if cr.Status.State != v2.AppStateReady {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions percona/controller/pgcluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,8 @@ func (r *PGClusterReconciler) reconcileExternalWatchers(ctx context.Context, cr
}

func (r *PGClusterReconciler) startExternalWatchers(ctx context.Context, cr *v2.PerconaPGCluster) error {
log := logging.FromContext(ctx)

if !cr.Spec.Backups.IsEnabled() {
return nil
}
Expand All @@ -986,8 +988,6 @@ func (r *PGClusterReconciler) startExternalWatchers(ctx context.Context, cr *v2.
return nil
}

log := logging.FromContext(ctx)

watcherName, watcherFunc := watcher.GetWALWatcher(cr)
if r.Watchers.IsExist(watcherName) {
return nil
Expand Down
12 changes: 9 additions & 3 deletions percona/watcher/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func GetWALWatcher(cr *pgv2.PerconaPGCluster) (string, WALWatcher) {
func WatchCommitTimestamps(ctx context.Context, cli client.Client, eventChan chan event.GenericEvent, stopChan chan event.DeleteEvent, cr *pgv2.PerconaPGCluster) {
log := logging.FromContext(ctx).WithName("WALWatcher")

if !cr.Spec.Backups.IsEnabled() {
return
}

log.Info("Watching commit timestamps")

execCli, err := clientcmd.NewClient()
Expand All @@ -52,15 +56,18 @@ func WatchCommitTimestamps(ctx context.Context, cli client.Client, eventChan cha
for {
select {
case <-ticker.C:
log.V(1).Info("Running WAL watcher")

localCr := cr.DeepCopy()
err := cli.Get(ctx, client.ObjectKeyFromObject(cr), localCr)
if err != nil {
log.Error(err, "get cluster")
return
}

if !localCr.Spec.Backups.IsEnabled() {
continue
}
log.V(1).Info("Running WAL watcher")

latestBackup, err := getLatestBackup(ctx, cli, localCr)
if err != nil {
if !errors.Is(err, errRunningBackup) && !errors.Is(err, errNoBackups) {
Expand All @@ -69,7 +76,6 @@ func WatchCommitTimestamps(ctx context.Context, cli client.Client, eventChan cha

continue
}

ts, err := GetLatestCommitTimestamp(ctx, cli, execCli, localCr, latestBackup)
if err != nil {
switch {
Expand Down
Loading