Skip to content

Commit

Permalink
fix test fail
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterYan committed Nov 4, 2024
1 parent 2ee404a commit d7cf653
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions pkg/supportbundle/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,21 +305,7 @@ func getExecOutputs(
return stdout.Bytes(), stderr.Bytes(), err
}

// Poll until stdout is non-empty or the context times out
ticker := time.NewTicker(100 * time.Millisecond) // Adjust polling frequency as needed
defer ticker.Stop()

for {
select {
case <-ticker.C:
if stdout.Len() > 0 {
return stdout.Bytes(), stderr.Bytes(), nil
}
case <-ctx.Done():
// Return whatever we have if context is canceled
return stdout.Bytes(), stderr.Bytes(), ctx.Err()
}
}
return stdout.Bytes(), stderr.Bytes(), nil
}

func runRemoteHostCollectors(ctx context.Context, hostCollectors []*troubleshootv1beta2.HostCollect, bundlePath string, opts SupportBundleCreateOpts) (map[string][]byte, error) {
Expand Down Expand Up @@ -398,8 +384,13 @@ func runRemoteHostCollectors(ctx context.Context, hostCollectors []*troubleshoot
for file, data := range result {
results[file] = []byte(data)
}

time.Sleep(1 * time.Second)
}

// wait for log stream to catch up
time.Sleep(1 * time.Second)

mu.Lock()
nodeLogs[pod.Spec.NodeName] = results
mu.Unlock()
Expand Down

0 comments on commit d7cf653

Please sign in to comment.