Skip to content

Commit d25aa7d

Browse files
banjohDexterYan
andauthored
fix: Do not fail analysis if node list does not exist (#1678)
* fix: Do not error if node list does not exist Signed-off-by: Evans Mungai <[email protected]> * fix test fail --------- Signed-off-by: Evans Mungai <[email protected]> Co-authored-by: Dexter Yan <[email protected]>
1 parent 77c9968 commit d25aa7d

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

pkg/analyze/collected_contents.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/pkg/errors"
88
"github.com/replicatedhq/troubleshoot/pkg/constants"
9+
"github.com/replicatedhq/troubleshoot/pkg/types"
910
)
1011

1112
type collectedContent struct {
@@ -33,6 +34,9 @@ func retrieveCollectedContents(
3334
// Local data not available, move to remote collection
3435
nodeListContents, err := getCollectedFileContents(constants.NODE_LIST_FILE)
3536
if err != nil {
37+
if _, ok := err.(*types.NotFoundError); ok {
38+
return collectedContents, nil
39+
}
3640
return nil, errors.Wrap(err, "failed to get node list")
3741
}
3842

pkg/analyze/collected_contents_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestRetrieveCollectedContents(t *testing.T) {
7878
remoteNodeBaseDir: "remoteBaseDir",
7979
remoteFileName: "remoteFileName",
8080
expectedResult: nil,
81-
expectedError: "failed to get node list",
81+
expectedError: "",
8282
},
8383
{
8484
name: "fail to retrieve content for one of the nodes",

pkg/supportbundle/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func getPodDetailsFromFiles(files map[string][]byte, podNamespace string, podNam
103103

104104
// GetFilesContents will return the file contents for filenames matching the filenames parameter.
105105
func GetFilesContents(bundleArchive string, filenames []string) (map[string][]byte, error) {
106-
bundleDir, err := ioutil.TempDir("", "troubleshoot")
106+
bundleDir, err := os.MkdirTemp("", "troubleshoot")
107107
if err != nil {
108108
return nil, errors.Wrap(err, "failed to create tmp dir")
109109
}

0 commit comments

Comments
 (0)