diff --git a/internal/controller/postgrescluster/pgbackrest.go b/internal/controller/postgrescluster/pgbackrest.go index 836df047fc..30b2415aaa 100644 --- a/internal/controller/postgrescluster/pgbackrest.go +++ b/internal/controller/postgrescluster/pgbackrest.go @@ -345,18 +345,6 @@ func (r *Reconciler) cleanupRepoResources(ctx context.Context, delete = false } } - case hasLabel(naming.LabelPGBackRestBackup): - if !backupsSpecFound { - break - } - // If a Job is identified for a repo that no longer exists in the spec then - // delete it. Otherwise add it to the slice and continue. - for _, repo := range postgresCluster.Spec.Backups.PGBackRest.Repos { - if repo.Name == owned.GetLabels()[naming.LabelPGBackRestRepo] { - ownedNoDelete = append(ownedNoDelete, owned) - delete = false - } - } case hasLabel(naming.LabelPGBackRestCronJob): if !backupsSpecFound { break @@ -371,6 +359,18 @@ func (r *Reconciler) cleanupRepoResources(ctx context.Context, break } } + case hasLabel(naming.LabelPGBackRestBackup): + if !backupsSpecFound { + break + } + // If a Job is identified for a repo that no longer exists in the spec then + // delete it. Otherwise add it to the slice and continue. + for _, repo := range postgresCluster.Spec.Backups.PGBackRest.Repos { + if repo.Name == owned.GetLabels()[naming.LabelPGBackRestRepo] { + ownedNoDelete = append(ownedNoDelete, owned) + delete = false + } + } case hasLabel(naming.LabelPGBackRestRestore): if !backupsSpecFound { break