Skip to content

Commit 350418c

Browse files
authored
feat(host-collector): add progress for host collector (#1659)
1 parent eacff71 commit 350418c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/supportbundle/collect.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,16 @@ func collectRemoteHost(ctx context.Context, collectSpecs []*troubleshootv1beta2.
227227

228228
isExcluded, _ := collector.IsExcluded()
229229
if isExcluded {
230-
opts.ProgressChan <- fmt.Sprintf("[%s] Excluding host collector", collector.Title())
230+
msg := fmt.Sprintf("[%s] Excluding host collector", collector.Title())
231+
opts.CollectorProgressCallback(opts.ProgressChan, msg)
231232
span.SetAttributes(attribute.Bool(constants.EXCLUDED, true))
232233
span.End()
233234
continue
234235
}
235236

236237
// Send progress event: starting the collector
237-
opts.ProgressChan <- fmt.Sprintf("[%s] Running host collector...", collector.Title())
238+
msg := fmt.Sprintf("[%s] Running host collector...", collector.Title())
239+
opts.CollectorProgressCallback(opts.ProgressChan, msg)
238240

239241
// Parameters for remote collection
240242
params := &collect.RemoteCollectParams{
@@ -255,12 +257,14 @@ func collectRemoteHost(ctx context.Context, collectSpecs []*troubleshootv1beta2.
255257
result, err := collect.RemoteHostCollect(ctx, *params)
256258
if err != nil {
257259
span.SetStatus(codes.Error, err.Error())
258-
opts.ProgressChan <- fmt.Sprintf("[%s] Error: %v", collector.Title(), err)
260+
msg = fmt.Sprintf("[%s] Error: %v", collector.Title(), err)
261+
opts.CollectorProgressCallback(opts.ProgressChan, msg)
259262
return errors.Wrap(err, "failed to run remote host collector")
260263
}
261264

262265
// Send progress event: completed successfully
263-
opts.ProgressChan <- fmt.Sprintf("[%s] Completed host collector", collector.Title())
266+
msg = fmt.Sprintf("[%s] Completed host collector", collector.Title())
267+
opts.CollectorProgressCallback(opts.ProgressChan, msg)
264268

265269
// Aggregate the results
266270
for k, v := range result {

0 commit comments

Comments
 (0)