mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-08-27 00:37:20 +00:00
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 <evans@replicated.com> * fix test fail --------- Signed-off-by: Evans Mungai <evans@replicated.com> Co-authored-by: Dexter Yan <yanshaocong@gmail.com>
This commit is contained in:
co-authored by
Dexter Yan
parent
77c9968ff6
commit
d25aa7d0ea
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user