From f01da1eae68c91a9ac571c0a20fd560d3063c8fb Mon Sep 17 00:00:00 2001 From: Ashish Ranjan Date: Thu, 9 Jan 2020 12:21:50 +0530 Subject: [PATCH] Fixes wrong placement of waitgroup.Add function Signed-off-by: Ashish Ranjan This commit fixes wrong placement of waitgroup.Add function in log collection method for `oc adm inspect` command. --- pkg/cli/admin/inspect/pod.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/cli/admin/inspect/pod.go b/pkg/cli/admin/inspect/pod.go index 81e28c588b..b19ce73217 100644 --- a/pkg/cli/admin/inspect/pod.go +++ b/pkg/cli/admin/inspect/pod.go @@ -288,8 +288,8 @@ func (o *InspectOptions) gatherContainerLogs(destDir string, pod *corev1.Pod, co wg := sync.WaitGroup{} errLock := sync.Mutex{} + wg.Add(1) go func() { - wg.Add(1) defer wg.Done() innerErrs := []error{} @@ -317,9 +317,8 @@ func (o *InspectOptions) gatherContainerLogs(destDir string, pod *corev1.Pod, co defer errLock.Unlock() errs = append(errs, innerErrs...) }() - + wg.Add(1) go func() { - wg.Add(1) defer wg.Done() innerErrs := []error{} @@ -347,6 +346,6 @@ func (o *InspectOptions) gatherContainerLogs(destDir string, pod *corev1.Pod, co defer errLock.Unlock() errs = append(errs, innerErrs...) }() - + wg.Wait() return utilerrors.NewAggregate(errs) }