fix(preflight): add tracing span and align error handling for host collector redaction (#2102)

* fix(preflight): add tracing span and align error handling for host collector redaction

Follow-up to #2101.

Adds an OpenTelemetry span around host collector redaction and returns the
unredacted collectResult on redaction failure, matching the behavior of
remote host collectors and in-cluster support-bundle collectors.

* fix(preflight): assign collected data before redaction so errors preserve output
This commit is contained in:
Xav Paice
2026-08-10 16:17:10 +01:00
committed by GitHub
parent 3db6a99d3a
commit b9faedfdb0
+10 -4
View File
@@ -145,17 +145,23 @@ func CollectHostWithContext(
span.End()
}
// The values of map entries will contain the collected data in bytes if the data was not stored to disk
collectResult.AllCollectedData = allCollectedData
// Local host preflight collectors are the only collection path (cluster,
// remote host, in-cluster support bundle) that skipped redaction entirely.
// A `run` collector's captured environment in particular can carry
// credentials verbatim (e.g. HTTPS_PROXY with embedded Basic Auth) into
// the bundle. See https://github.com/replicatedhq/troubleshoot/issues/2100.
_, span := otel.Tracer(constants.LIB_TRACER_NAME).Start(ctx, "Host collectors")
span.SetAttributes(attribute.String("type", "Redactors"))
if err := collect.RedactResult(opts.BundlePath, collect.CollectorResult(allCollectedData), nil); err != nil {
return nil, errors.Wrap(err, "failed to redact host collector results")
err = errors.Wrap(err, "failed to redact host collector results")
span.SetStatus(codes.Error, err.Error())
span.End()
return collectResult, err
}
// The values of map entries will contain the collected data in bytes if the data was not stored to disk
collectResult.AllCollectedData = allCollectedData
span.End()
return collectResult, nil
}