diff --git a/cmd/preflight/cli/run.go b/cmd/preflight/cli/run.go index 878cd106..065e435c 100644 --- a/cmd/preflight/cli/run.go +++ b/cmd/preflight/cli/run.go @@ -121,6 +121,20 @@ func runPreflights(v *viper.Viper, arg string) error { } } }() + } else { + // make sure we don't block any senders + go func() { + for { + select { + case _, ok := <-progressCh: + if !ok { + return + } + case <-finishedCh: + return + } + } + }() } defer func() { diff --git a/pkg/preflight/collect.go b/pkg/preflight/collect.go index b2e5b937..c8daef2d 100644 --- a/pkg/preflight/collect.go +++ b/pkg/preflight/collect.go @@ -18,6 +18,11 @@ type CollectOpts struct { ProgressChan chan interface{} } +type CollectProgress struct { + Name string + Status string +} + type CollectResult interface { Analyze() []*analyze.AnalyzeResult IsRBACAllowed() bool @@ -144,12 +149,22 @@ func Collect(opts CollectOpts, p *troubleshootv1beta2.Preflight) (CollectResult, } } + opts.ProgressChan <- CollectProgress{ + Name: collector.GetDisplayName(), + Status: "running", + } + result, err := collector.RunCollectorSync(nil) if err != nil { opts.ProgressChan <- errors.Errorf("failed to run collector %s: %v\n", collector.GetDisplayName(), err) continue } + opts.ProgressChan <- CollectProgress{ + Name: collector.GetDisplayName(), + Status: "completed", + } + if result != nil { for k, v := range result { allCollectedData[k] = v