Skip to content

Commit 0da9305

Browse files
committed
Fix: Issue 164: Capture output of exec to files before overall job failure check
* Otherwise we fail to capture output from running pods when there is at least one other pod containing the same pod string such as nginx-ingress
1 parent 4c91202 commit 0da9305

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/jobs/job.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ func (j Job) Collect(dc *data_collector.DataCollector) (error, bool, []string) {
6161
dc.Logger.Printf("\tJob %s has been skipped\n---\n", j.Name)
6262
return nil, true, files
6363
}
64-
if jobResults.Error != nil {
65-
dc.Logger.Printf("\tJob %s has failed: %s\n", j.Name, jobResults.Error)
66-
return jobResults.Error, false, files
67-
}
6864

6965
for fileName, fileValue := range jobResults.Files {
7066
err := os.MkdirAll(filepath.Dir(fileName), os.ModePerm)
@@ -79,6 +75,13 @@ func (j Job) Collect(dc *data_collector.DataCollector) (error, bool, []string) {
7975
_ = file.Close()
8076
dc.Logger.Printf("\tJob %s wrote %d bytes to %s\n", j.Name, len(fileValue), fileName)
8177
}
78+
79+
if jobResults.Error != nil {
80+
dc.Logger.Printf("\tJob %s has failed: %s\n", j.Name, jobResults.Error)
81+
fmt.Printf("Files collected so far: %v\n", files)
82+
return jobResults.Error, false, files
83+
}
84+
8285
dc.Logger.Printf("\tJob %s completed successfully\n---\n", j.Name)
8386
return nil, false, files
8487
}

0 commit comments

Comments
 (0)