Skip to content

Commit

Permalink
fix: Do not fail analysis if node list does not exist (#1678)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
banjoh and DexterYan authored Nov 7, 2024
1 parent 77c9968 commit d25aa7d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/analyze/collected_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/pkg/errors"
"github.com/replicatedhq/troubleshoot/pkg/constants"
"github.com/replicatedhq/troubleshoot/pkg/types"
)

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

Expand Down
2 changes: 1 addition & 1 deletion pkg/analyze/collected_contents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestRetrieveCollectedContents(t *testing.T) {
remoteNodeBaseDir: "remoteBaseDir",
remoteFileName: "remoteFileName",
expectedResult: nil,
expectedError: "failed to get node list",
expectedError: "",
},
{
name: "fail to retrieve content for one of the nodes",
Expand Down
2 changes: 1 addition & 1 deletion pkg/supportbundle/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func getPodDetailsFromFiles(files map[string][]byte, podNamespace string, podNam

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

0 comments on commit d25aa7d

Please sign in to comment.