Skip to content

Commit

Permalink
cluster: fix cannot use exec command when hostname contain '-' (#1794)
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored Mar 14, 2022
1 parent b736fb4 commit b5b109e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cluster/manager/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (m *Manager) Exec(name string, opt ExecOptions, gOpt operator.Options) erro
var shellTasks []task.Task
uniqueHosts := map[string]set.StringSet{} // host-sshPort -> {command}
topo.IterInstance(func(inst spec.Instance) {
key := fmt.Sprintf("%s-%d", inst.GetHost(), inst.GetSSHPort())
key := fmt.Sprintf("%s:%d", inst.GetHost(), inst.GetSSHPort())
if _, found := uniqueHosts[key]; !found {
if len(gOpt.Roles) > 0 && !filterRoles.Exist(inst.Role()) {
return
Expand All @@ -80,7 +80,7 @@ func (m *Manager) Exec(name string, opt ExecOptions, gOpt operator.Options) erro
})

for hostKey, i := range uniqueHosts {
host := strings.Split(hostKey, "-")[0]
host := strings.Split(hostKey, ":")[0]
for _, cmd := range i.Slice() {
shellTasks = append(shellTasks,
task.NewBuilder(m.logger).
Expand Down

0 comments on commit b5b109e

Please sign in to comment.