From 5c0b83805728ca8c6b78ec0243daa2f3d90c5d0d Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Thu, 7 Nov 2024 18:58:24 +0000 Subject: [PATCH 1/2] fix: Do not error if node list does not exist Signed-off-by: Evans Mungai --- pkg/analyze/collected_contents.go | 4 ++++ pkg/supportbundle/parse.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/analyze/collected_contents.go b/pkg/analyze/collected_contents.go index 753a6a65c..8d5e8a228 100644 --- a/pkg/analyze/collected_contents.go +++ b/pkg/analyze/collected_contents.go @@ -6,6 +6,7 @@ import ( "github.com/pkg/errors" "github.com/replicatedhq/troubleshoot/pkg/constants" + "github.com/replicatedhq/troubleshoot/pkg/types" ) type collectedContent struct { @@ -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") } diff --git a/pkg/supportbundle/parse.go b/pkg/supportbundle/parse.go index e88433510..c755b55c4 100644 --- a/pkg/supportbundle/parse.go +++ b/pkg/supportbundle/parse.go @@ -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") } From bb62a3dbf9eff7b235b684bd8f7a5055fccccf83 Mon Sep 17 00:00:00 2001 From: Dexter Yan Date: Fri, 8 Nov 2024 09:25:26 +1300 Subject: [PATCH 2/2] fix test fail --- pkg/analyze/collected_contents_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/analyze/collected_contents_test.go b/pkg/analyze/collected_contents_test.go index c7200b4db..92d09d701 100644 --- a/pkg/analyze/collected_contents_test.go +++ b/pkg/analyze/collected_contents_test.go @@ -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",