e2e: remove passing waitgroups reference for go routines

We are unwantedly passing around waitgroups which is not required.
This address the same inside e2e/rbd_helper.go and remove the waitgroup
arg

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-06-28 13:58:46 +05:30 committed by mergify[bot]
parent 7f7a41d23a
commit 053f7ee213

View File

@ -268,7 +268,6 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
var wg sync.WaitGroup var wg sync.WaitGroup
totalCount := 10 totalCount := 10
wgErrs := make([]error, totalCount) wgErrs := make([]error, totalCount)
wg.Add(totalCount)
pvc, err := loadPVC(pvcPath) pvc, err := loadPVC(pvcPath)
if err != nil { if err != nil {
return fmt.Errorf("failed to load PVC with error %v", err) return fmt.Errorf("failed to load PVC with error %v", err)
@ -284,12 +283,13 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
snap.Namespace = f.UniqueName snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
// create snapshot // create snapshot
wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout) wgErrs[n] = createSnapshot(&s, deployTimeout)
w.Done() wg.Done()
}(&wg, i, snap) }(i, snap)
} }
wg.Wait() wg.Wait()
@ -324,11 +324,11 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
// create multiple PVCs from same snapshot // create multiple PVCs from same snapshot
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()
@ -348,12 +348,12 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a) wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()
@ -372,11 +372,11 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
wg.Add(totalCount) wg.Add(totalCount)
// delete snapshot // delete snapshot
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = deleteSnapshot(&s, deployTimeout) wgErrs[n] = deleteSnapshot(&s, deployTimeout)
w.Done() wg.Done()
}(&wg, i, snap) }(i, snap)
} }
wg.Wait() wg.Wait()