-
Notifications
You must be signed in to change notification settings - Fork 32
K8SPS-535: fix more delete-backup
finalizer issues
#1113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 fixes finalizer-related issues in the backup deletion process. The changes improve the handling of backup deletion finalizers and address object listing behavior.
- Simplifies finalizer logic by removing unnecessary state checks and improving early return conditions
- Implements retry mechanism with fresh object retrieval when updating finalizers
- Fixes object listing path by adding trailing slash to destination
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
pkg/controller/psbackup/controller.go | Updates finalizer handling logic and adds debug print statements |
cmd/sidecar/handler/backup/handler.go | Fixes object listing path by adding trailing slash |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
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.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
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 4 out of 4 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
require.NoError(t, r.Delete(t.Context(), cr)) | ||
|
||
// Getting backup with deletion timestamp | ||
if err := r.Get(t.Context(), client.ObjectKeyFromObject(cr), cr); err != nil { | ||
if k8serrors.IsNotFound(err) && len(tt.expectedFinalizers) == 0 { | ||
return | ||
} | ||
t.Fatal(err) | ||
} | ||
cr := new(apiv1.PerconaServerMySQLBackup) | ||
if err := r.Get(ctx, types.NamespacedName{Name: tt.cr.Name, Namespace: tt.cr.Namespace}, cr); err != nil { | ||
if k8serrors.IsNotFound(err) && len(cr.Finalizers) == 0 { | ||
|
||
assert.NoError(t, r.checkFinalizers(t.Context(), cr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method t.Context()
is not a standard Go testing method. This should be context.Background()
or define a proper context variable.
Copilot uses AI. Check for mistakes.
require.NoError(t, r.Delete(t.Context(), cr)) | ||
|
||
// Getting backup with deletion timestamp | ||
if err := r.Get(t.Context(), client.ObjectKeyFromObject(cr), cr); err != nil { | ||
if k8serrors.IsNotFound(err) && len(tt.expectedFinalizers) == 0 { | ||
return | ||
} | ||
t.Fatal(err) | ||
} | ||
cr := new(apiv1.PerconaServerMySQLBackup) | ||
if err := r.Get(ctx, types.NamespacedName{Name: tt.cr.Name, Namespace: tt.cr.Namespace}, cr); err != nil { | ||
if k8serrors.IsNotFound(err) && len(cr.Finalizers) == 0 { | ||
|
||
assert.NoError(t, r.checkFinalizers(t.Context(), cr)) | ||
|
||
// Getting backup with updated finalizers | ||
if err := r.Get(t.Context(), client.ObjectKeyFromObject(cr), cr); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method t.Context()
is not a standard Go testing method. These should use context.Background()
or a properly defined context variable.
Copilot uses AI. Check for mistakes.
require.NoError(t, r.Delete(t.Context(), cr)) | ||
|
||
// Getting backup with deletion timestamp | ||
if err := r.Get(t.Context(), client.ObjectKeyFromObject(cr), cr); err != nil { | ||
if k8serrors.IsNotFound(err) && len(tt.expectedFinalizers) == 0 { | ||
return | ||
} | ||
t.Fatal(err) | ||
} | ||
cr := new(apiv1.PerconaServerMySQLBackup) | ||
if err := r.Get(ctx, types.NamespacedName{Name: tt.cr.Name, Namespace: tt.cr.Namespace}, cr); err != nil { | ||
if k8serrors.IsNotFound(err) && len(cr.Finalizers) == 0 { | ||
|
||
assert.NoError(t, r.checkFinalizers(t.Context(), cr)) | ||
|
||
// Getting backup with updated finalizers | ||
if err := r.Get(t.Context(), client.ObjectKeyFromObject(cr), cr); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method t.Context()
is not a standard Go testing method. These should use context.Background()
or a properly defined context variable.
Copilot uses AI. Check for mistakes.
commit: 42af5a8 |
https://perconadev.atlassian.net/browse/K8SPS-535
DESCRIPTION
This PR addresses two additional issues related to the
percona.com/delete-backup
finalizer:backupExists
function in the backup sidecar lists an MD5 file of the backup.xbcloud
does not count this file as part of the backup, so the finalizer fails to delete when only this md5 file exists. This function should only check files in the backup directory.PerconaServerMySQLBackup
object that still contains finalizers even though the backup has already been deleted. This caused the operator to rerun the finalizer. After that, it attempts to update the backup resource which resulted in errors like:Operation cannot be fulfilled on perconaservermysqlbackups...
. To fix this, we should check if the backup object actually exists before updaring.CHECKLIST
Jira
Needs Doc
) and QA (Needs QA
)?Tests
Config/Logging/Testability