Conversation
gkech
reviewed
Apr 17, 2025
Comment on lines
+27
to
+36
| func (f *fakeClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, options ...client.PatchOption) error { | ||
| err := f.Client.Patch(ctx, obj, patch, options...) | ||
| if !k8serrors.IsNotFound(err) { | ||
| return err | ||
| } | ||
| if err := f.Create(ctx, obj); err != nil { | ||
| return err | ||
| } | ||
| return f.Client.Patch(ctx, obj, patch, options...) | ||
| } |
Contributor
There was a problem hiding this comment.
Do we need this? By removing it nothing fails on the controller tests.
|
|
||
| func finishBackup(ctx context.Context, c client.Client, pgBackup *v2.PerconaPGBackup, job *batchv1.Job) (*reconcile.Result, error) { | ||
| if checkBackupJob(job) == v2.BackupSucceeded { | ||
| if job != nil && checkBackupJob(job) == v2.BackupSucceeded { |
Contributor
There was a problem hiding this comment.
Should we maybe validate the input job once at the top of the function and avoid repeating the same check across different places?
e.g.
func finishBackup(ctx context.Context, c client.Client, pgBackup *v2.PerconaPGBackup, job *batchv1.Job) (*reconcile.Result, error) {
if job == nil {
// do something
}
Contributor
Author
There was a problem hiding this comment.
It will be clearer to repeat this check. We can't change the order of each action in this function, so if we add the if job == nil check at the top, it will just have a lot of duplicated code.
gkech
approved these changes
Apr 18, 2025
egegunes
approved these changes
Apr 18, 2025
hors
approved these changes
Apr 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://perconadev.atlassian.net/browse/K8SPG-680
DESCRIPTION
Problem:
After a failed PVC resize on
cluster1-repo1, scheduled backups cannot be created successfully. Although thepg-backupobject is created, it gets stuck in theStartingstate.Cause:
When a PVC resize fails, the crunchy's
PostgresClusterresource gets anUnknownstatus for thePGBackRestReplicaRepoReadycondition. This condition is required to create a backup job in thereconcileManualBackupmethod:percona-postgresql-operator/internal/controller/postgrescluster/pgbackrest.go
Lines 2394 to 2407 in bd5bac1
As a result, the operator waits indefinitely for the backup job to appear:
percona-postgresql-operator/percona/controller/pgbackup/controller.go
Lines 190 to 195 in bd5bac1
Solution:
.status.conditionsfield to thePerconaPGClusterresource.PostgresClusterresource (PGBackRestRepoHostReadyandPGBackRestReplicaCreate) are notTrue, a newReadyForBackupcondition is added toPerconaPGClusterwith theFalsestatus.ReadyForBackupisFalse, the operator will skip the scheduled backup creation and log a message instead.PerconaPGBackupresource is created and the operator is waiting for its backup job to appear, it will check theReadyForBackupcondition. If it was set toFalsemore than 2 minutes ago, the backup will be marked asFailed.CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability