Skip to content

K8SPG-870 Use delta as size for incr and diff backups#1696

Open
oksana-grishchenko wants to merge 6 commits into
mainfrom
K8SPG-870-use-delta-as-size-for-incr-and-diff
Open

K8SPG-870 Use delta as size for incr and diff backups#1696
oksana-grishchenko wants to merge 6 commits into
mainfrom
K8SPG-870-use-delta-as-size-for-incr-and-diff

Conversation

@oksana-grishchenko

@oksana-grishchenko oksana-grishchenko commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

K8SPG-870

Problem:
We were reporting info.size that is the entire size of the backup, even for incremental/differential.

Solution:
Use delta for incremental/differential. For full backups delta is the same as size so we can use delta for all types of backups.

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?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates how the operator reports backup size in PerconaPGBackup status by using pgBackRest’s delta value so incremental/differential backups no longer show the full backup size.

Changes:

  • Extend the pgBackRest info JSON parsing struct to include info.delta.
  • Update PGBackup status reconciliation to store backup.Info.Delta as the reported Status.Size.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
percona/pgbackrest/pgbackrest.go Adds delta to the parsed pgBackRest backup info payload.
percona/controller/pgbackup/controller.go Switches PGBackup status size calculation from info.size to info.delta.

Comment thread percona/controller/pgbackup/controller.go
Comment thread percona/pgbackrest/pgbackrest.go Outdated
Type v2.PGBackupType `json:"type,omitempty"`
Info struct {
Size int64 `json:"size,omitempty"`
Size int64 `json:"size,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right, now it can be safely deleted. Updated, thanks

}

if pgBackup.Status.BackupName != backup.Label || pgBackup.Status.BackupType != backup.Type || pgBackup.Status.Size != backup.Info.Size {
if pgBackup.Status.BackupName != backup.Label || pgBackup.Status.BackupType != backup.Type || pgBackup.Status.Size != backup.Info.Delta {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lets try to see if we can capture this part through a unit test and assert the status value and its population

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added unit-tests to check status while different conditions take place.

we also have a basic e2e test that checks the size is populated

kubectl wait --for=jsonpath='{.status.state}'=Succeeded --timeout=560s -n "${NAMESPACE}" pg-backup/demand-backup-full-repo1
kubectl wait --for=jsonpath='{.status.backupType}'=full --timeout=120s -n "${NAMESPACE}" pg-backup/demand-backup-full-repo1
kubectl -n "${NAMESPACE}" get pg-backup demand-backup-full-repo1 -o json | jq -e '.status.size != null' >/dev/null
kubectl wait --for=jsonpath='{.status.state}'=Succeeded --timeout=560s -n "${NAMESPACE}" pg-backup/demand-backup-differential-repo1
kubectl wait --for=jsonpath='{.status.backupType}'=diff --timeout=120s -n "${NAMESPACE}" pg-backup/demand-backup-differential-repo1
kubectl -n "${NAMESPACE}" get pg-backup demand-backup-differential-repo1 -o json | jq -e '.status.size != null' >/dev/null
kubectl wait --for=jsonpath='{.status.state}'=Succeeded --timeout=560s -n "${NAMESPACE}" pg-backup/demand-backup-incremental-repo1
kubectl wait --for=jsonpath='{.status.backupType}'=incr --timeout=120s -n "${NAMESPACE}" pg-backup/demand-backup-incremental-repo1
kubectl -n "${NAMESPACE}" get pg-backup demand-backup-incremental-repo1 -o json | jq -e '.status.size != null' >/dev/null

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

percona/controller/pgbackup/controller.go:540

    1. Problem: The behavior change to populate pgBackup.Status.Size from backup.Info.Delta isn’t covered by a unit test that exercises updatePGBackrestInfo (only findBackupInPGBackrestInfo is tested).
  1. Why it matters: This is user-visible status data; without a direct test, a refactor could accidentally stop propagating delta to .status.size.
  2. Fix: Add a focused unit test for updatePGBackrestInfo (or extract a small helper like applyBackupStatus(pgBackup, backup) and test that it sets Status.Size = backup.Info.Delta).
	if pgBackup.Status.BackupName != backup.Label || pgBackup.Status.BackupType != backup.Type || pgBackup.Status.Size != backup.Info.Delta {
		if err := pgBackup.UpdateStatus(ctx, c, func(bcp *v2.PerconaPGBackup) {
			bcp.Status.BackupName = backup.Label
			bcp.Status.BackupType = backup.Type
			bcp.Status.Size = backup.Info.Delta

Comment thread percona/controller/pgbackup/controller_test.go
egegunes
egegunes previously approved these changes Jul 23, 2026
Type v2.PGBackupType `json:"type,omitempty"`
Info struct {
Size int64 `json:"size,omitempty"`
Delta int64 `json:"delta,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

adding a comment about delta being equal to size for full backups might be helpful for future readers of code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done fa632b8

@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
backup-enable-disable passed 00:00:00
builtin-extensions passed 00:00:00
cert-manager-tls passed 00:00:00
custom-envs passed 00:00:00
custom-tls passed 00:00:00
database-init-sql passed 00:00:00
demand-backup passed 00:00:00
demand-backup-offline-snapshot passed 00:00:00
dynamic-configuration passed 00:00:00
finalizers passed 00:00:00
init-deploy passed 00:00:00
huge-pages passed 00:00:00
major-upgrade-14-to-15 passed 00:00:00
major-upgrade-15-to-16 passed 00:00:00
major-upgrade-16-to-17 passed 00:00:00
major-upgrade-17-to-18 passed 00:00:00
ldap passed 00:00:00
ldap-tls passed 00:00:00
monitoring passed 00:00:00
monitoring-pmm3 passed 00:00:00
one-pod passed 00:00:00
operator-self-healing passed 00:00:00
pgbouncer-mtls passed 00:00:00
pitr passed 00:00:00
scaling passed 00:00:00
scheduled-backup passed 00:00:00
self-healing passed 00:00:00
sidecars passed 00:00:00
standby-pgbackrest passed 00:00:00
standby-streaming passed 00:00:00
start-from-backup passed 00:00:00
tablespaces passed 00:00:00
telemetry-transfer passed 00:00:00
upgrade-consistency passed 00:00:00
upgrade-minor passed 00:00:00
users passed 00:00:00
migration-from-crunchy-standby passed 00:00:00
migration-from-crunchy-pv passed 00:00:00
migration-from-crunchy-backup-restore passed 00:00:00
Summary Value
Tests Run 39/39
Job Duration 00:20:33
Total Test Time N/A

commit: 9e91f9b
image: perconalab/percona-postgresql-operator:PR-1696-9e91f9bc7

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.

5 participants