Skip to content

Commit

Permalink
feat(host-collector): add progress for host collector (#1659)
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterYan authored Oct 25, 2024
1 parent eacff71 commit 350418c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/supportbundle/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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 {
Expand Down

0 comments on commit 350418c

Please sign in to comment.