Skip to content

Commit

Permalink
fix channel stuff
Browse files Browse the repository at this point in the history
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
  • Loading branch information
Anshul Ahuja committed Oct 16, 2023
1 parent 1908c30 commit a61b8e6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/backup/item_backupper.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (ib *itemBackupper) executeActions(
// Async call the current CSI Plugin's Execute()
// Wait for all snapshots to complete.
// Max parallelism can be controlled by further tweaking the WaitGroup.
additionalItemFilesChannel := make(chan []FileForArchive)
additionalItemFilesChannel := make(chan FileForArchive)
errChannel := make(chan error)
var wg sync.WaitGroup
for _, additionalItem := range additionalItemIdentifiers {
Expand Down Expand Up @@ -451,25 +451,27 @@ func (ib *itemBackupper) executeActions(
}
wg.Add(1)

Check warning on line 452 in pkg/backup/item_backupper.go

View check run for this annotation

Codecov / codecov/patch

pkg/backup/item_backupper.go#L452

Added line #L452 was not covered by tests
go func(additionalItem velero.ResourceIdentifier, log logrus.FieldLogger, item runtime.Unstructured, gvr schema.GroupVersionResource, mustInclude, finalize bool) {
defer wg.Done()
log.WithFields(logrus.Fields{
"groupResource": additionalItem.GroupResource,
"namespace": additionalItem.Namespace,
"name": additionalItem.Name,
}).Infof("Triggering async backupitem for additional item")
defer wg.Done()
_, additionalItemFiles, err := ib.backupItem(log, item, gvr.GroupResource(), gvr, mustInclude, finalize)
if err != nil {
errChannel <- err
return
}
additionalItemFilesChannel <- additionalItemFiles
for _, file := range additionalItemFiles {

Check warning on line 465 in pkg/backup/item_backupper.go

View check run for this annotation

Codecov / codecov/patch

pkg/backup/item_backupper.go#L463-L465

Added lines #L463 - L465 were not covered by tests
additionalItemFilesChannel <- file
}
}(additionalItem, log, item.DeepCopy(), gvr, mustInclude, finalize)

Check warning on line 468 in pkg/backup/item_backupper.go

View check run for this annotation

Codecov / codecov/patch

pkg/backup/item_backupper.go#L467-L468

Added lines #L467 - L468 were not covered by tests
}
wg.Wait()
close(additionalItemFilesChannel)
close(errChannel)
for itemFilesFromChannel := range additionalItemFilesChannel {
itemFiles = append(itemFiles, itemFilesFromChannel...)
itemFiles = append(itemFiles, itemFilesFromChannel)
}
for err := range errChannel {

Check warning on line 476 in pkg/backup/item_backupper.go

View check run for this annotation

Codecov / codecov/patch

pkg/backup/item_backupper.go#L475-L476

Added lines #L475 - L476 were not covered by tests
return nil, itemFiles, err
Expand Down

0 comments on commit a61b8e6

Please sign in to comment.