Skip to content

Commit dbd2c62

Browse files
committed
OCPBUGS-34953: analyze: improve error msg when gather fails
Give a better error message when the gather logs are not collected rather than ``` time="2024-06-05T08:34:45-04:00" level=error msg="The bootstrap machine did not execute the release-image.service systemd unit" ``` The release-image service could have been executed but we don't know if the installer cannot connect to the bootstrap node (e.g, in a private install).
1 parent a651e1a commit dbd2c62

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pkg/gather/service/analyze.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func analyzeGatherBundle(bundleFile io.Reader) error {
4444
// read through the tar for relevant files
4545
tarReader := tar.NewReader(uncompressedStream)
4646
serviceAnalyses := make(map[string]analysis)
47+
servicesFound := make([]string, 0)
4748
for {
4849
header, err := tarReader.Next()
4950
if err == io.EOF {
@@ -61,6 +62,7 @@ func analyzeGatherBundle(bundleFile io.Reader) error {
6162
continue
6263
}
6364
serviceName := serviceEntriesFileSubmatch[1]
65+
servicesFound = append(servicesFound, serviceName)
6466

6567
serviceAnalysis, err := analyzeService(tarReader)
6668
if err != nil {
@@ -71,6 +73,11 @@ func analyzeGatherBundle(bundleFile io.Reader) error {
7173
serviceAnalyses[serviceName] = serviceAnalysis
7274
}
7375

76+
if len(servicesFound) == 0 {
77+
logrus.Error("Invalid log bundle or the bootstrap machine could not be reached and bootstrap logs were not collected")
78+
return nil
79+
}
80+
7481
analysisChecks := []struct {
7582
name string
7683
check func(analysis) bool

pkg/gather/service/analyze_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestAnalyzeGatherBundle(t *testing.T) {
5454
{
5555
name: "no files",
5656
expectedOutput: []logrus.Entry{
57-
{Level: logrus.ErrorLevel, Message: "The bootstrap machine did not execute the release-image.service systemd unit"},
57+
{Level: logrus.ErrorLevel, Message: "Invalid log bundle or the bootstrap machine could not be reached and bootstrap logs were not collected"},
5858
},
5959
},
6060
{

0 commit comments

Comments
 (0)