Skip base finding steps if we don't need bases (#5066)

Minor optimization where we skip trying to find BackupBases if we know
we're going to end up dropping them anyway. This can save us from
loading all the kopia manifests only to discard the information we
pulled from them. Note that this optimization only kicks in for
backups that request no merge bases and no assist bases
("full backup")

Existing test coverage in `operations/manifests_test.go` ensures this
doesn't break base selection altogether

As this is an optimization we don't need to merge this PR if it seems
like it will make code maintenance more difficult going forward

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

* #<issue>

#### Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [x] 💚 E2E
This commit is contained in:
ashmrtn 2024-01-24 09:05:34 -08:00 committed by GitHub
parent db5b73e74d
commit 963d0e3fef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -75,6 +75,10 @@ type BackupBases interface {
SnapshotAssistBases() []BackupBase SnapshotAssistBases() []BackupBase
} }
func EmptyBackupBase() BackupBases {
return &backupBases{}
}
type backupBases struct { type backupBases struct {
mergeBases []BackupBase mergeBases []BackupBase
assistBases []BackupBase assistBases []BackupBase

View File

@ -24,6 +24,17 @@ func produceManifestsAndMetadata(
tenantID string, tenantID string,
getMetadata, dropAssistBases bool, getMetadata, dropAssistBases bool,
) (kopia.BackupBases, []data.RestoreCollection, bool, error) { ) (kopia.BackupBases, []data.RestoreCollection, bool, error) {
// Just return early if we're going to end up dropping all the bases anyway.
// This will avoid loading kopia manifest data in the case that we're doing a
// full enumeration and refetching all item data for the resource.
//
// It's easier to work through later logic if we know that the returned
// kopia.BackupBases is non-nil for non-error cases so return a trivial
// implementation here.
if !getMetadata && dropAssistBases {
return kopia.EmptyBackupBase(), nil, false, nil
}
bb, meta, useMergeBases, err := getManifestsAndMetadata( bb, meta, useMergeBases, err := getManifestsAndMetadata(
ctx, ctx,
bf, bf,