Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(host-collector): add progress for host collector #1659

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
xavpaice marked this conversation as resolved.
Show resolved Hide resolved
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
Loading