Skip to content

Commit 0cfd431

Browse files
committed
Fix missing longhorn logs
1 parent fe5dd3e commit 0cfd431

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pkg/collect/ceph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ func cephCommandExec(ctx context.Context, c *Collector, cephCollector *troublesh
133133
return errors.Wrap(err, "failed to exec command")
134134
}
135135

136+
pathPrefix := GetCephCollectorFilepath(cephCollector.CollectorName, cephCollector.Namespace)
136137
for srcFilename, _ := range results {
137-
pathPrefix := GetCephCollectorFilepath(cephCollector.CollectorName, cephCollector.Namespace)
138138
var dstFileName string
139139
switch {
140140
case strings.HasSuffix(srcFilename, "-stdout.txt"):

pkg/collect/longhorn.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"bytes"
66
"context"
77
"fmt"
8+
"path"
89
"path/filepath"
910
"regexp"
1011
"sync"
@@ -205,9 +206,12 @@ func Longhorn(c *Collector, longhornCollector *troubleshootv1beta2.Longhorn) (Co
205206
return nil, errors.Wrap(err, "collect longhorn logs")
206207
}
207208
logsDir := GetLonghornLogsDirectory(ns)
208-
for key, log := range logs {
209-
key = filepath.Join(logsDir, key)
210-
output.SaveResult(c.BundlePath, key, bytes.NewBuffer(log))
209+
for srcFilename, _ := range logs {
210+
dstFileName := path.Join(logsDir, srcFilename)
211+
err := copyResult(logs, output, c.BundlePath, srcFilename, dstFileName)
212+
if err != nil {
213+
logger.Printf("Failed to copy file %s; %v", srcFilename, err)
214+
}
211215
}
212216

213217
// https://longhorn.io/docs/1.1.1/advanced-resources/data-recovery/corrupted-replica/

pkg/collect/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (r CollectorResult) GetReader(bundlePath string, relativePath string) (io.R
9595
}
9696

9797
filename := filepath.Join(bundlePath, relativePath)
98-
f, err := os.Open(filename)
98+
f, err := os.Open(filename) // does this ever close?
9999
if err != nil {
100100
return nil, errors.Wrap(err, "failed to open file")
101101
}

0 commit comments

Comments
 (0)