@@ -35,7 +35,16 @@ import (
35
35
)
36
36
37
37
// DockerLogCollector collect logs from a CAPD workload cluster.
38
- type DockerLogCollector struct {}
38
+ type DockerLogCollector struct {
39
+ AdditionalLogs []AdditionalLogs
40
+ }
41
+
42
+ // AdditionalLogs is a struct to hold instruction for additional logs that need to be collected.
43
+ type AdditionalLogs struct {
44
+ OutputFileName string
45
+ Command string
46
+ Args []string
47
+ }
39
48
40
49
// machineContainerName return a container name using the same rule used in CAPD.
41
50
// NOTE: if the cluster name is already included in the machine name, the cluster name is not add thus
@@ -149,7 +158,8 @@ func (k DockerLogCollector) collectLogsFromNode(ctx context.Context, outputPath
149
158
return osExec .Command ("tar" , "--extract" , "--file" , tempfileName , "--directory" , outputDir ).Run () //nolint:gosec // We don't care about command injection here.
150
159
}
151
160
}
152
- return errors .AggregateConcurrent ([]func () error {
161
+
162
+ collectFuncs := []func () error {
153
163
execToPathFn (
154
164
"journal.log" ,
155
165
"journalctl" , "--no-pager" , "--output=short-precise" ,
@@ -175,7 +185,13 @@ func (k DockerLogCollector) collectLogsFromNode(ctx context.Context, outputPath
175
185
"journalctl" , "--no-pager" , "--output=short-precise" , "-u" , "containerd.service" ,
176
186
),
177
187
copyDirFn ("/var/log/pods" , "pods" ),
178
- })
188
+ }
189
+
190
+ for _ , additionalLogs := range k .AdditionalLogs {
191
+ collectFuncs = append (collectFuncs , execToPathFn (additionalLogs .OutputFileName , additionalLogs .Command , additionalLogs .Args ... ))
192
+ }
193
+
194
+ return errors .AggregateConcurrent (collectFuncs )
179
195
}
180
196
181
197
// fileOnHost is a helper to create a file at path
0 commit comments