From 053f7ee2134dd3683f9448660d5d30a51540b5f2 Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Mon, 28 Jun 2021 13:58:46 +0530 Subject: [PATCH] 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 --- e2e/rbd_helper.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index a5577662f..e68826cc9 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -268,7 +268,6 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc, var wg sync.WaitGroup totalCount := 10 wgErrs := make([]error, totalCount) - wg.Add(totalCount) pvc, err := loadPVC(pvcPath) if err != nil { 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.Spec.Source.PersistentVolumeClaimName = &pvc.Name // create snapshot + wg.Add(totalCount) 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) wgErrs[n] = createSnapshot(&s, deployTimeout) - w.Done() - }(&wg, i, snap) + wg.Done() + }(i, snap) } wg.Wait() @@ -324,11 +324,11 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc, // create multiple PVCs from same snapshot wg.Add(totalCount) 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) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) - w.Done() - }(&wg, i, *pvcClone, *appClone) + wg.Done() + }(i, *pvcClone, *appClone) } wg.Wait() @@ -348,12 +348,12 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc, wg.Add(totalCount) // delete clone and app 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) p.Spec.DataSource.Name = name wgErrs[n] = deletePVCAndApp(name, f, &p, &a) - w.Done() - }(&wg, i, *pvcClone, *appClone) + wg.Done() + }(i, *pvcClone, *appClone) } wg.Wait() @@ -372,11 +372,11 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc, wg.Add(totalCount) // delete snapshot 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) wgErrs[n] = deleteSnapshot(&s, deployTimeout) - w.Done() - }(&wg, i, snap) + wg.Done() + }(i, snap) } wg.Wait()