Skip to content

Commit

Permalink
Merge pull request #1152 from cumirror/master
Browse files Browse the repository at this point in the history
Fix #1151: Probabilistic panic when create clusters with multiple nodes
  • Loading branch information
ks-ci-bot authored Mar 24, 2022
2 parents c81fe6f + 1358b2a commit e162538
Showing 1 changed file with 15 additions and 7 deletions.
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

0 comments on commit e162538

Please sign in to comment.