Skip to content

Conversation

@oksana-grishchenko
Copy link

@oksana-grishchenko oksana-grishchenko commented Jan 8, 2026

K8SPG-904 Powered by Pull Request Badge

Allow no repos when restoring from dataSource

Problem:
K8SPG-904 When restoring from dataSource while backups are disabled, the restore job fails to be created.

Cause:
The crunchyv1beta1.Backups.PGBackRest.Image was never set if the backups were disabled which caused the following error:

Job.batch "cluster1-pgbackrest-restore" is invalid: spec.template.spec.initContainers[0].image: Required value`

Solution:
Init the crunchyv1beta1.Backups.PGBackRest.Image with the given image from the PG CR.

Note: if the crunchyv1beta1.Backups.PGBackRest.Image is set then the repohost sts appears which was the cause why the backup-enable-disable e2e test was failing on step 2.
So the following changes are also applied:

  • the codebase is updated to set the crunchyv1beta1.Backups.PGBackRest.Image only if the pg cluster has datasource
  • the backup-enable-disable test is updated so that in addition to the regular cluster creation it also creates a cluster from datasource, checks the repohost sts appearance and the presense of the image in crunchyv1beta1.Backups.PGBackRest.Image

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PG version?
  • Does the change support oldest and newest supported Kubernetes version?

@it-percona-cla
Copy link

it-percona-cla commented Jan 8, 2026

CLA assistant check
All committers have signed the CLA.

Comment on lines 507 to 511
return crunchyv1beta1.Backups{
PGBackRest: crunchyv1beta1.PGBackRestArchive{
Image: b.PGBackRest.Image,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crunchy controller decides whether backups are disabled by comparing backup spec with crunchyv1beta1.Backups{PGBackRest: crunchyv1beta1.PGBackRestArchive{}}

backupsSpecFound = !reflect.DeepEqual(postgresCluster.Spec.Backups, v1beta1.Backups{PGBackRest: v1beta1.PGBackRestArchive{}})

will this affect that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will (in a way).
That's why the backup-enable-disable test was updated to show how a cluster without repos but with dataSource is expected to work. Which is: in case we specify the image in the crunchyv1beta1.Backups{PGBackRest: crunchyv1beta1.PGBackRestArchive{}} section, crunchy considers backups as enabled indeed, however since there are no repos defined, it's only expected that the sts will be created for repohost but no backup job should be created until we enable the backups. It's being explicitly checked in this new test step

Please let me know if you have any concerns about this behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to not create the sts for repohost?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently there is this RELATED_IMAGE_PGBACKREST env var for crunchy cluster that should do the trick without defining the image in the .backups.pgbackrest section. That could potentially allow to reach the goal but avoid creating sts. I'll play around with it and get back.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

posted the current state to the related ticket, the work on it is paused until the proper solution is found.

@oksana-grishchenko oksana-grishchenko marked this pull request as draft January 20, 2026 14:58
@JNKPercona
Copy link
Collaborator

Test Name Result Time
backup-enable-disable failure 00:00:00
custom-envs failure 00:00:00
custom-extensions failure 00:00:00
custom-tls failure 00:00:00
database-init-sql skipped 00:00:00
demand-backup skipped 00:00:00
finalizers skipped 00:00:00
init-deploy skipped 00:00:00
monitoring skipped 00:00:00
monitoring-pmm3 skipped 00:00:00
one-pod skipped 00:00:00
operator-self-healing skipped 00:00:00
pgvector-extension skipped 00:00:00
pitr skipped 00:00:00
scaling skipped 00:00:00
scheduled-backup skipped 00:00:00
self-healing skipped 00:00:00
sidecars skipped 00:00:00
start-from-backup skipped 00:00:00
tablespaces skipped 00:00:00
telemetry-transfer skipped 00:00:00
upgrade-consistency skipped 00:00:00
upgrade-minor skipped 00:00:00
users skipped 00:00:00
Summary Value
Tests Run 4/24
Job Duration 00:16:35
Total Test Time N/A

commit: 1588646
image: perconalab/percona-postgresql-operator:PR-1395-158864689

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants