Skip to content

Commit

Permalink
Sync from server repo (fecd4672746)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Spilchen committed Sep 13, 2023
1 parent e69a1e6 commit 871e603
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
24 changes: 21 additions & 3 deletions vclusterops/nma_download_file_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ func (e *ClusterLeaseNotExpiredError) Error() string {
e.Expiration)
}

// ReviveDBNodeCountMismatchError is returned when the number of nodes in new cluster
// does not match the number of nodes in original cluster
type ReviveDBNodeCountMismatchError struct {
ReviveDBStep string
FailureHost string
NumOfNewNodes int
NumOfOldNodes int
}

func (e *ReviveDBNodeCountMismatchError) Error() string {
return fmt.Sprintf(`[%s] nodes mismatch found on host %s: the number of the new nodes in --hosts is %d,`+
` but the number of the old nodes in description file is %d`,
e.ReviveDBStep, e.FailureHost, e.NumOfNewNodes, e.NumOfOldNodes)
}

func makeNMADownloadFileOp(newNodes []string, sourceFilePath, destinationFilePath, catalogPath string,
communalStorageParameters map[string]string, vdb *VCoordinationDatabase, displayOnly, ignoreClusterLease bool) (NMADownloadFileOp, error) {
op := NMADownloadFileOp{}
Expand Down Expand Up @@ -195,9 +210,12 @@ func (op *NMADownloadFileOp) processResult(execContext *OpEngineExecContext) err
}

if len(descFileContent.NodeList) != len(op.newNodes) {
err := fmt.Errorf(`[%s] nodes mismatch found on host %s: the number of the new nodes in --hosts is %d,`+
` but the number of the old nodes in description file is %d`,
op.name, host, len(op.newNodes), len(descFileContent.NodeList))
err := &ReviveDBNodeCountMismatchError{
ReviveDBStep: op.name,
FailureHost: host,
NumOfNewNodes: len(op.newNodes),
NumOfOldNodes: len(descFileContent.NodeList),
}
allErrs = errors.Join(allErrs, err)
break
}
Expand Down
3 changes: 2 additions & 1 deletion vclusterops/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ func GetCleanPath(path string) string {
return path
}
cleanPath := strings.TrimSpace(path)
cleanPath = strings.ReplaceAll(cleanPath, "//", "/")
// clean and normalize the path
cleanPath = filepath.Clean(cleanPath)
return cleanPath
}

Expand Down
16 changes: 16 additions & 0 deletions vclusterops/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ func TestGetCleanPath(t *testing.T) {
res = GetCleanPath(path)
assert.Equal(t, res, "/data")

path = "///data"
res = GetCleanPath(path)
assert.Equal(t, res, "/data")

path = "////data"
res = GetCleanPath(path)
assert.Equal(t, res, "/data")

path = "///data/"
res = GetCleanPath(path)
assert.Equal(t, res, "/data")

path = "//scratch_b/qa/data/"
res = GetCleanPath(path)
assert.Equal(t, res, "/scratch_b/qa/data")

path = "//data "
res = GetCleanPath(path)
assert.Equal(t, res, "/data")
Expand Down

0 comments on commit 871e603

Please sign in to comment.