Skip to content

Conversation

@pooknull
Copy link
Contributor

@pooknull pooknull commented Nov 20, 2025

K8SPXC-1144 Powered by Pull Request Badge

https://perconadev.atlassian.net/browse/K8SPXC-1144

DESCRIPTION

Problem:
When performing a PITR restore using backupSource, we currently do not throw an error when a gap is detected.

Solution:
The operator should create a file named <backup-name>.pitr-not-ready in the storage whenever a gap is detected.
Before starting a restore, the operator must check whether this file exists in the storage, and if it does, the operator should throw an error.

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?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

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 PXC version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size bot added the size/L 100-499 lines label Nov 20, 2025
@pooknull pooknull marked this pull request as ready for review November 24, 2025 11:47
Comment on lines 120 to 131
objReader, err := stg.GetObject(ctx, filepath)
if err != nil {
if !errors.Is(err, storage.ErrObjectNotFound) {
return false, errors.Wrap(err, "get pitr-not-ready file from storage")
}
found = false
} else {
objReader.Close()
}

return !found, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

feel free the reject but i think this version can be more readable and we can get rid of found variable

Suggested change
objReader, err := stg.GetObject(ctx, filepath)
if err != nil {
if !errors.Is(err, storage.ErrObjectNotFound) {
return false, errors.Wrap(err, "get pitr-not-ready file from storage")
}
found = false
} else {
objReader.Close()
}
return !found, nil
}
if err == nil || errors.Is(err, storage.ErrObjectNotFound) {
objReader.Close()
return false, nil
}
return false, errors.Wrap(err, "get pitr-not-ready file from storage")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pooknull pooknull requested a review from egegunes November 27, 2025 11:59
egegunes
egegunes previously approved these changes Nov 28, 2025
lastSetFilePrefix string = "last-binlog-set-" // filename prefix for object where the last binlog set will stored
gtidPostfix string = "-gtid-set" // filename postfix for files with GTID set
timelinePath string = "/tmp/pitr-timeline" // path to file with timeline
lastSetFilePrefix string = "last-binlog-set-" // filename prefix for object where the last binlog set will stored
Copy link
Contributor

Choose a reason for hiding this comment

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

will be stored

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}
scli, err := storageFunc(ctx, opts)
if err != nil {
return errors.Wrap(err, "failed to create s3 client")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the s3 client always the case for storage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filepath := bcp.Status.Destination.BackupName() + "." + naming.PITRNotReady
objReader, err := stg.GetObject(ctx, filepath)
if err == nil {
objReader.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

should we handle the error this returns?

Copy link
Contributor

Choose a reason for hiding this comment

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

At least we can log it, maybe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We handle it below

@JNKPercona
Copy link
Collaborator

Test Name Result Time
auto-tuning-8-0 passed 00:20:18
allocator-8-0 passed 00:12:02
backup-storage-tls-8-0 passed 00:23:19
cross-site-8-0 passed 00:34:37
custom-users-8-0 passed 00:11:36
demand-backup-cloud-8-0 passed 00:54:59
demand-backup-encrypted-with-tls-8-0 passed 00:43:59
demand-backup-8-0 passed 00:41:38
demand-backup-flow-control-8-0 passed 00:11:02
demand-backup-parallel-8-0 passed 00:10:02
demand-backup-without-passwords-8-0 passed 00:15:04
haproxy-5-7 passed 00:13:23
haproxy-8-0 passed 00:13:28
init-deploy-5-7 passed 00:15:45
init-deploy-8-0 passed 00:16:19
limits-8-0 passed 00:11:58
monitoring-2-0-8-0 passed 00:22:15
monitoring-pmm3-8-0 passed 00:18:22
one-pod-5-7 passed 00:14:19
one-pod-8-0 passed 00:12:32
pitr-8-0 passed 00:44:15
pitr-gap-errors-8-0 passed 00:54:00
proxy-protocol-8-0 passed 00:09:24
proxy-switch-8-0 passed 00:13:52
proxysql-sidecar-res-limits-8-0 passed 00:08:22
proxysql-scheduler-8-0 passed 00:16:03
pvc-resize-5-7 passed 00:14:43
pvc-resize-8-0 passed 00:15:47
recreate-8-0 passed 00:16:33
restore-to-encrypted-cluster-8-0 passed 00:25:27
scaling-proxysql-8-0 passed 00:08:16
scaling-8-0 passed 00:11:11
scheduled-backup-5-7 passed 01:02:38
scheduled-backup-8-0 passed 00:59:50
security-context-8-0 passed 00:25:26
smart-update1-8-0 passed 00:32:29
smart-update2-8-0 passed 00:37:37
storage-8-0 passed 00:10:15
tls-issue-cert-manager-ref-8-0 passed 00:08:18
tls-issue-cert-manager-8-0 passed 00:09:17
tls-issue-self-8-0 passed 00:12:46
upgrade-consistency-8-0 passed 00:10:41
upgrade-haproxy-5-7 passed 00:24:37
upgrade-haproxy-8-0 passed 00:23:57
upgrade-proxysql-5-7 passed 00:13:16
upgrade-proxysql-8-0 passed 00:14:10
users-5-7 passed 00:25:09
users-8-0 passed 00:26:01
validation-hook-8-0 passed 00:01:54
Summary Value
Tests Run 49/49
Job Duration 02:25:02
Total Test Time 17:33:36

commit: 65dc354
image: perconalab/percona-xtradb-cluster-operator:PR-2261-65dc3545

@hors hors merged commit f1ee4b9 into main Dec 1, 2025
10 of 12 checks passed
@hors hors deleted the K8SPXC-1144 branch December 1, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 100-499 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants