Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1151: Probabilistic panic when create clusters with multiple nodes #1152

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions pkg/core/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package util
import (
"bytes"
"fmt"
"github.com/pkg/errors"
"math"
"os"
"os/exec"
Expand All @@ -28,6 +27,8 @@ import (
"sort"
"strings"
"text/template"

"github.com/pkg/errors"
)

type Data map[string]interface{}
Expand Down Expand Up @@ -92,20 +93,27 @@ func homeWindows() (string, error) {
}

func GetArgs(argsMap map[string]string, args []string) ([]string, map[string]string) {
for _, arg := range args {
targetMap := make(map[string]string, len(argsMap))
for k, v := range argsMap {
targetMap[k] = v
}
targetSlice := make([]string, len(args))
copy(targetSlice, args)

for _, arg := range targetSlice {
splitArg := strings.SplitN(arg, "=", 2)
if len(splitArg) < 2 {
continue
}
argsMap[splitArg[0]] = splitArg[1]
targetMap[splitArg[0]] = splitArg[1]
}

for arg, value := range argsMap {
for arg, value := range targetMap {
cmd := fmt.Sprintf("%s=%s", arg, value)
args = append(args, cmd)
targetSlice = append(targetSlice, cmd)
}
sort.Strings(args)
return args, argsMap
sort.Strings(targetSlice)
return targetSlice, targetMap
}

// Round returns the result of rounding 'val' according to the specified 'precision' precision (the number of digits after the decimal point)。
Expand Down