Improve logging/variable grouping for exchange preview backup (#4705)

Just shuffling some variables and log statements around. No logic or
test changes beyond that

---

#### 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
- [x] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-11-16 19:48:53 -08:00 committed by GitHub
parent 0fcbf75f6f
commit 8e978cce37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,24 +135,21 @@ func populateCollections(
category = qp.Category category = qp.Category
// Limits and counters below are currently only used for preview backups // Limits and counters below are currently only used for preview backups
// since they only act on a subset of items. // since they only act on a subset of items. Make a copy of the passed in
maxContainers = ctrlOpts.PreviewLimits.MaxContainers // limits so we can log both the passed in options and what they were set to
maxItemsPerContainer = ctrlOpts.PreviewLimits.MaxItemsPerContainer // if we used default values for some things.
maxItems = ctrlOpts.PreviewLimits.MaxItems effectiveLimits = ctrlOpts.PreviewLimits
addedItems int addedItems int
addedContainers int addedContainers int
) )
logger.Ctx(ctx).Infow("filling collections", "len_deltapaths", len(dps))
counter.Add(count.PrevDeltas, int64(len(dps)))
el := errs.Local() el := errs.Local()
// Preview backups select a reduced set of data. This is managed by ordering // Preview backups select a reduced set of data. This is managed by ordering
// the set of results from the container resolver and reducing the number of // the set of results from the container resolver and reducing the number of
// items selected from each container. // items selected from each container.
if ctrlOpts.PreviewLimits.Enabled { if effectiveLimits.Enabled {
resolver, err = newRankedContainerResolver( resolver, err = newRankedContainerResolver(
ctx, ctx,
resolver, resolver,
@ -169,24 +166,25 @@ func populateCollections(
} }
// Configure limits with reasonable defaults if they're not set. // Configure limits with reasonable defaults if they're not set.
if maxContainers == 0 { if effectiveLimits.MaxContainers == 0 {
maxContainers = defaultPreviewContainerLimit effectiveLimits.MaxContainers = defaultPreviewContainerLimit
} }
if maxItemsPerContainer == 0 { if effectiveLimits.MaxItemsPerContainer == 0 {
maxItemsPerContainer = defaultPreviewItemsPerContainerLimit effectiveLimits.MaxItemsPerContainer = defaultPreviewItemsPerContainerLimit
} }
if maxItems == 0 { if effectiveLimits.MaxItems == 0 {
maxItems = defaultPreviewItemLimit effectiveLimits.MaxItems = defaultPreviewItemLimit
}
} }
logger.Ctx(ctx).Infow( logger.Ctx(ctx).Infow(
"running preview backup", "filling collections",
"item_limit", maxItems, "len_deltapaths", len(dps),
"container_limit", maxContainers, "limits", ctrlOpts.PreviewLimits,
"items_per_container_limit", maxItemsPerContainer) "effective_limits", effectiveLimits)
} counter.Add(count.PrevDeltas, int64(len(dps)))
for _, c := range resolver.Items() { for _, c := range resolver.Items() {
if el.Failure() != nil { if el.Failure() != nil {
@ -244,15 +242,15 @@ func populateCollections(
// Since part of this is about figuring out how many items to get for this // Since part of this is about figuring out how many items to get for this
// particular container we need to reconfigure for every container we see. // particular container we need to reconfigure for every container we see.
if ctrlOpts.PreviewLimits.Enabled { if effectiveLimits.Enabled {
toAdd := maxItems - addedItems toAdd := effectiveLimits.MaxItems - addedItems
if addedContainers >= maxContainers || toAdd <= 0 { if addedContainers >= effectiveLimits.MaxContainers || toAdd <= 0 {
break break
} }
if toAdd > maxItemsPerContainer { if toAdd > effectiveLimits.MaxItemsPerContainer {
toAdd = maxItemsPerContainer toAdd = effectiveLimits.MaxItemsPerContainer
} }
// Delta tokens generated with this CallConfig shouldn't be used for // Delta tokens generated with this CallConfig shouldn't be used for