diff --git a/pkg/collect/result.go b/pkg/collect/result.go index 997de6104..efd9b7ee1 100644 --- a/pkg/collect/result.go +++ b/pkg/collect/result.go @@ -132,7 +132,7 @@ func (r CollectorResult) SaveResult(bundlePath string, relativePath string, read return errors.Wrap(err, "failed to stat file") } - klog.V(2).Infof("Added %q (%d MB) to bundle output", relativePath, fileInfo.Size()/(1024*1024)) + klog.V(2).Infof("Added %q (%d KB) to bundle output", relativePath, fileInfo.Size()/(1024)) return nil } diff --git a/pkg/redact/literal.go b/pkg/redact/literal.go index b87221526..79c93c5d2 100644 --- a/pkg/redact/literal.go +++ b/pkg/redact/literal.go @@ -3,9 +3,11 @@ package redact import ( "bufio" "bytes" + "fmt" "io" "github.com/replicatedhq/troubleshoot/pkg/constants" + "k8s.io/klog/v2" ) type literalRedactor struct { @@ -29,9 +31,15 @@ func (r literalRedactor) Redact(input io.Reader, path string) io.Reader { go func() { var err error defer func() { - if err == io.EOF { + if err == nil || err == io.EOF { writer.Close() } else { + if err == bufio.ErrTooLong { + s := fmt.Sprintf("Error redacting %q. A line in the file exceeded %d MB max length", path, constants.SCANNER_MAX_SIZE/1024/1024) + klog.V(2).Info(s) + } else { + klog.V(2).Info(fmt.Sprintf("Error redacting %q: %v", path, err)) + } writer.CloseWithError(err) } }() diff --git a/pkg/redact/single_line.go b/pkg/redact/single_line.go index 918f979b7..b620e3ded 100644 --- a/pkg/redact/single_line.go +++ b/pkg/redact/single_line.go @@ -3,10 +3,12 @@ package redact import ( "bufio" "bytes" + "fmt" "io" "regexp" "github.com/replicatedhq/troubleshoot/pkg/constants" + "k8s.io/klog/v2" ) type SingleLineRedactor struct { @@ -41,9 +43,15 @@ func (r *SingleLineRedactor) Redact(input io.Reader, path string) io.Reader { go func() { var err error defer func() { - if err == io.EOF { + if err == nil || err == io.EOF { writer.Close() } else { + if err == bufio.ErrTooLong { + s := fmt.Sprintf("Error redacting %q. A line in the file exceeded %d MB max length", path, constants.SCANNER_MAX_SIZE/1024/1024) + klog.V(2).Info(s) + } else { + klog.V(2).Info(fmt.Sprintf("Error redacting %q: %v", path, err)) + } writer.CloseWithError(err) } }()