Skip to content

Commit 2f34561

Browse files
author
Andrew Reed
authored
Merge pull request #368 from areed/longhorn-pod-logs
Collect all longhorn pod logs
2 parents ed6b336 + a86f5ca commit 2f34561

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pkg/collect/longhorn.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ func Longhorn(c *Collector, longhornCollector *troubleshootv1beta2.Longhorn) (ma
182182
}
183183
final[settingsKey] = settingsB
184184

185+
// logs of all pods in namespace
186+
logsCollector := &troubleshootv1beta2.Logs{
187+
Selector: []string{""},
188+
Namespace: ns,
189+
}
190+
logs, err := Logs(c, logsCollector)
191+
if err != nil {
192+
return nil, errors.Wrap(err, "collect longhorn logs")
193+
}
194+
logsDir := GetLonghornLogsDirectory(ns)
195+
for key, log := range logs {
196+
key = filepath.Join(logsDir, key)
197+
final[key] = log
198+
}
199+
185200
return final, nil
186201
}
187202

@@ -254,3 +269,10 @@ func GetLonghornSettingsFile(namespace string) string {
254269
}
255270
return "longhorn/settings.yaml"
256271
}
272+
273+
func GetLonghornLogsDirectory(namespace string) string {
274+
if namespace != DefaultLonghornNamespace {
275+
return fmt.Sprintf("longhorn/%s/logs", namespace)
276+
}
277+
return "longhorn/logs"
278+
}

0 commit comments

Comments
 (0)