-
Notifications
You must be signed in to change notification settings - Fork 112
PBM-1649 Support profiles in cleanup and delete-backup #1227
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
base: dev
Are you sure you want to change the base?
Conversation
a6e953d to
ec8d7c1
Compare
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 adds support for storage profiles in cleanup and delete-backup operations, allowing users to specify a profile when cleaning up or deleting backups stored in different storage configurations.
- Added
profileparameter to cleanup and delete-backup commands and their underlying functions - Updated backup filtering logic to support profile-based queries
- Modified storage initialization to use profile-specific configurations when provided
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/sdk.go | Added profile field to DeleteBackupBeforeOptions and updated function signatures to pass profile parameter |
| sdk/impl.go | Updated client methods to accept and pass profile parameter for cleanup and delete operations |
| pbm/util/storage.go | Added GetProfiledStorage function to retrieve storage configuration from a specific profile |
| pbm/ctrl/send.go | Updated command sending functions to include profile parameter in delete and cleanup commands |
| pbm/ctrl/cmd.go | Added Profile field to DeleteBackupCmd and CleanupCmd structures |
| pbm/backup/delete.go | Updated delete and cleanup functions to filter backups by profile and use profile-specific storage |
| cmd/pbm/main.go | Added --profile flag to cleanup and delete-backup CLI commands |
| cmd/pbm/delete.go | Added profile validation and parameter passing in CLI handlers |
| cmd/pbm-agent/delete.go | Updated agent delete and cleanup handlers to use profile parameter and changed from DeleteBackupFiles to DeleteBackup |
Comments suppressed due to low confidence (1)
cmd/pbm-agent/delete.go:265
- The storage instance
stgcreated at line 262 is no longer used after the change tobackup.DeleteBackupat line 292. Thestgvariable is only used for deleting chunks (line 280), so the error handling at line 259 should return early if there's an error, or the storage initialization should be moved closer to where it's actually used (before the chunk deletion loop at line 276).
stg, err := util.StorageFromConfig(&cfg.Storage, a.brief.Me, l)
if err != nil {
l.Error("get storage: " + err.Error())
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ec8d7c1 to
ae2ec70
Compare
ae2ec70 to
f8454a8
Compare
boris-ilijic
left a comment
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.
Approach looks good, I dropped few comments on some of the (use) cases we need to smooth out.
| if d.bcpType != "" && d.olderThan == "" { | ||
| return nil, errors.New("cannot use --type without --older-than") | ||
| } | ||
| if d.profile != "" { |
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.
Probably we should forbidden delete by name in combination with --profile:
pbm delete <backup-name> --profile p1
In case when backup-name is on default storage or on e.g. p2, above command will still delete backup, so that's kind of misleading.
Alternative is to not delete that backup in case when that backup-name is not present within the profile storage, but I'd recommend the first solution.
04ec70f to
5ba0497
Compare
… the cleanup cli command.
… invalid name and flag combinations
c34fb94 to
c9db0ed
Compare
…avoid duplicate logic
6aeebb7 to
ce35b59
Compare
boris-ilijic
left a comment
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.
There's one bug related to bulk delete that must be addressed before merging. All other comments are optional.
Once that bug is fixed, the PR is ready to merge.
|
|
||
| l.Info("deleting backups older than %v", t) | ||
| err = backup.DeleteBackupBefore(ctx, a.leadConn, t, bcpType, nodeInfo.Me) | ||
| stg, err := util.GetProfiledStorage(ctx, a.leadConn, d.Profile, nodeInfo.Me, l) |
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.
This will result in an error during bulk delete on the main storage.
pbm/backup/delete.go
Outdated
| // TODO: Do we keep this? Is this true? | ||
| // It may seems that if PITR is ON and there is no continuous oplog range between snapshot and `ts`, | ||
| // that there must be a more recent base snapshot for PITR. | ||
| // However PITR might had been enabled and the first oplog chunk was not recorder yet. | ||
| if nextRestoreTime.IsZero() { | ||
| // TODO: comment seems to be wrong |
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.
I would not analyze this at this moment, seems complex and requires time to analyze it better. So, I am suggesting to keep more or less original comments.
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.
I rephrased the todo, but there there was no comment before.
Since it is complex, I would rather keep it with a note that it might not be accurate (and I'm reasonably certain it is) instead of having to figure it out all over again in the future.
ce35b59 to
672ad55
Compare
… being considered a base for PITR
Uh oh!
There was an error while loading. Please reload this page.