From 350418c6e93e60791ed499700dfe10b9ad3723a7 Mon Sep 17 00:00:00 2001 From: Dexter Yan Date: Fri, 25 Oct 2024 15:34:09 +1300 Subject: [PATCH] feat(host-collector): add progress for host collector (#1659) --- pkg/supportbundle/collect.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/supportbundle/collect.go b/pkg/supportbundle/collect.go index ec8e680c2..87ff2fcfb 100644 --- a/pkg/supportbundle/collect.go +++ b/pkg/supportbundle/collect.go @@ -227,14 +227,16 @@ func collectRemoteHost(ctx context.Context, collectSpecs []*troubleshootv1beta2. isExcluded, _ := collector.IsExcluded() if isExcluded { - opts.ProgressChan <- fmt.Sprintf("[%s] Excluding host collector", collector.Title()) + msg := fmt.Sprintf("[%s] Excluding host collector", collector.Title()) + opts.CollectorProgressCallback(opts.ProgressChan, msg) span.SetAttributes(attribute.Bool(constants.EXCLUDED, true)) span.End() continue } // Send progress event: starting the collector - opts.ProgressChan <- fmt.Sprintf("[%s] Running host collector...", collector.Title()) + msg := fmt.Sprintf("[%s] Running host collector...", collector.Title()) + opts.CollectorProgressCallback(opts.ProgressChan, msg) // Parameters for remote collection params := &collect.RemoteCollectParams{ @@ -255,12 +257,14 @@ func collectRemoteHost(ctx context.Context, collectSpecs []*troubleshootv1beta2. result, err := collect.RemoteHostCollect(ctx, *params) if err != nil { span.SetStatus(codes.Error, err.Error()) - opts.ProgressChan <- fmt.Sprintf("[%s] Error: %v", collector.Title(), err) + msg = fmt.Sprintf("[%s] Error: %v", collector.Title(), err) + opts.CollectorProgressCallback(opts.ProgressChan, msg) return errors.Wrap(err, "failed to run remote host collector") } // Send progress event: completed successfully - opts.ProgressChan <- fmt.Sprintf("[%s] Completed host collector", collector.Title()) + msg = fmt.Sprintf("[%s] Completed host collector", collector.Title()) + opts.CollectorProgressCallback(opts.ProgressChan, msg) // Aggregate the results for k, v := range result {