Skip to content

feat(backup): prevent backups on hibernated clusters#8870

Merged
leonardoce merged 2 commits intomainfrom
dev/8508
Oct 21, 2025
Merged

feat(backup): prevent backups on hibernated clusters#8870
leonardoce merged 2 commits intomainfrom
dev/8508

Conversation

@armru
Copy link
Member

@armru armru commented Oct 15, 2025

Add hibernation validation in BackupReconciler.checkPrerequisites to fail backups when the target cluster has hibernation enabled.

The validation follows the existing pattern where prerequisite checks are performed in the backup controller after the Backup resource is created. When hibernation is detected, the backup is marked as failed with reason "ClusterIsHibernated" and a warning event is recorded on the Backup resource itself.

This approach is consistent with how other prerequisite failures are handled (e.g., missing backup configuration, missing plugins, no VolumeSnapshot support), allowing the error to be visible directly on the Backup object regardless of how it was created (manually, via ScheduledBackup, or other means).

Related #8508

@armru armru requested a review from a team as a code owner October 15, 2025 16:01
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.26 release-1.27 labels Oct 15, 2025
@github-actions
Copy link
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@armru armru added do not backport This PR must not be backported - it will be in the next minor release and removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.26 release-1.27 labels Oct 15, 2025
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement 🪄 New feature or request labels Oct 15, 2025
@armru
Copy link
Member Author

armru commented Oct 16, 2025

/test limit=local

@github-actions
Copy link
Contributor

@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/18560926214

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 20, 2025
Add hibernation validation in BackupReconciler.checkPrerequisites to
fail backups when the target cluster has hibernation enabled.

The validation follows the existing pattern where prerequisite checks
are performed in the backup controller after the Backup resource is
created. When hibernation is detected, the backup is marked as failed
with reason "ClusterIsHibernated" and a warning event is recorded on
the Backup resource itself.

This approach is consistent with how other prerequisite failures are
handled (e.g., missing backup configuration, missing plugins, no
VolumeSnapshot support), allowing the error to be visible directly on
the Backup object regardless of how it was created (manually, via
ScheduledBackup, or other means).

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
@leonardoce
Copy link
Contributor

/ok-to-merge

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Oct 21, 2025
@leonardoce leonardoce merged commit fb9e1f9 into main Oct 21, 2025
35 of 36 checks passed
@leonardoce leonardoce deleted the dev/8508 branch October 21, 2025 13:02
@gbartolini
Copy link
Contributor

gbartolini commented Oct 21, 2025

This should be tracked as a "change" in 1.28. Just curious, why did you guys decide not to backport this?

@leonardoce
Copy link
Contributor

This should be tracked as a "change" in 1.28. Just curious, why did you guys decide not to backport this?

Because the patch was designed as a feature that clarifies the reason of an error condition.
Yep, we could definitely backport it.

gbartolini pushed a commit that referenced this pull request Oct 22, 2025
Add hibernation validation in `BackupReconciler.checkPrerequisites` to
fail backups when the target cluster has hibernation enabled.

The validation follows the existing pattern where prerequisite checks
are performed in the backup controller after the Backup resource is
created. When hibernation is detected, the backup is marked as failed
with reason `ClusterIsHibernated` and a warning event is recorded on the
Backup resource itself.

This approach is consistent with how other prerequisite failures are
handled (e.g., missing backup configuration, missing plugins, no
`VolumeSnapshot` support), allowing the error to be visible directly on
the Backup object regardless of how it was created (manually, via
`ScheduledBackup`, or other means).

Related #8508

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
(cherry picked from commit fb9e1f9)
@leonardoce
Copy link
Contributor

@armru what do you think?

@mnencia mnencia removed the do not backport This PR must not be backported - it will be in the next minor release label Oct 22, 2025
@mnencia mnencia added backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.26 release-1.27 labels Oct 22, 2025
mnencia pushed a commit that referenced this pull request Oct 22, 2025
Add hibernation validation in `BackupReconciler.checkPrerequisites` to
fail backups when the target cluster has hibernation enabled.

The validation follows the existing pattern where prerequisite checks
are performed in the backup controller after the Backup resource is
created. When hibernation is detected, the backup is marked as failed
with reason `ClusterIsHibernated` and a warning event is recorded on the
Backup resource itself.

This approach is consistent with how other prerequisite failures are
handled (e.g., missing backup configuration, missing plugins, no
`VolumeSnapshot` support), allowing the error to be visible directly on
the Backup object regardless of how it was created (manually, via
`ScheduledBackup`, or other means).

Related #8508

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
(cherry picked from commit fb9e1f9)
mnencia pushed a commit that referenced this pull request Oct 22, 2025
Add hibernation validation in `BackupReconciler.checkPrerequisites` to
fail backups when the target cluster has hibernation enabled.

The validation follows the existing pattern where prerequisite checks
are performed in the backup controller after the Backup resource is
created. When hibernation is detected, the backup is marked as failed
with reason `ClusterIsHibernated` and a warning event is recorded on the
Backup resource itself.

This approach is consistent with how other prerequisite failures are
handled (e.g., missing backup configuration, missing plugins, no
`VolumeSnapshot` support), allowing the error to be visible directly on
the Backup object regardless of how it was created (manually, via
`ScheduledBackup`, or other means).

Related #8508

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
(cherry picked from commit fb9e1f9)
@mnencia mnencia linked an issue Oct 29, 2025 that may be closed by this pull request
4 tasks
THE-BRAHMA pushed a commit to THE-BRAHMA/cloudnative-pg that referenced this pull request Oct 30, 2025
…8870)

Add hibernation validation in `BackupReconciler.checkPrerequisites` to
fail backups when the target cluster has hibernation enabled.

The validation follows the existing pattern where prerequisite checks
are performed in the backup controller after the Backup resource is
created. When hibernation is detected, the backup is marked as failed
with reason `ClusterIsHibernated` and a warning event is recorded on the
Backup resource itself.

This approach is consistent with how other prerequisite failures are
handled (e.g., missing backup configuration, missing plugins, no
`VolumeSnapshot` support), allowing the error to be visible directly on
the Backup object regardless of how it was created (manually, via
`ScheduledBackup`, or other means).

Related cloudnative-pg#8508

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Signed-off-by: theBrahma <office.utpal.brahma@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases enhancement 🪄 New feature or request lgtm This PR has been approved by a maintainer ok to merge 👌 This PR can be merged release-1.25 release-1.26 release-1.27 size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Backups are still tried for hibernated clusters

5 participants