Skip to content

Conversation

@jcechace
Copy link
Collaborator

@jcechace jcechace commented Nov 13, 2025

PBM-1649 Powered by Pull Request Badge

Copy link
Contributor

Copilot AI left a 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 profile parameter 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 stg created at line 262 is no longer used after the change to backup.DeleteBackup at line 292. The stg variable 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.

@jcechace jcechace force-pushed the PBM-1649-cleanup-profiles branch from ec8d7c1 to ae2ec70 Compare November 18, 2025 12:11
@jcechace jcechace force-pushed the PBM-1649-cleanup-profiles branch from ae2ec70 to f8454a8 Compare November 18, 2025 12:37
@jcechace jcechace marked this pull request as ready for review November 18, 2025 23:14
Copy link
Member

@boris-ilijic boris-ilijic left a 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 != "" {
Copy link
Member

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.

@jcechace jcechace force-pushed the PBM-1649-cleanup-profiles branch from 04ec70f to 5ba0497 Compare November 20, 2025 16:04
@jcechace jcechace force-pushed the PBM-1649-cleanup-profiles branch 2 times, most recently from c34fb94 to c9db0ed Compare November 24, 2025 20:48
@jcechace jcechace force-pushed the PBM-1649-cleanup-profiles branch from 6aeebb7 to ce35b59 Compare November 25, 2025 16:57
Copy link
Member

@boris-ilijic boris-ilijic left a 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)
Copy link
Member

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.

Comment on lines 491 to 496
// 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
Copy link
Member

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.

Copy link
Collaborator Author

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.

@jcechace jcechace force-pushed the PBM-1649-cleanup-profiles branch from ce35b59 to 672ad55 Compare November 27, 2025 09:06
@boris-ilijic boris-ilijic self-requested a review November 27, 2025 09:51
boris-ilijic
boris-ilijic previously approved these changes Nov 27, 2025
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.

2 participants