From b5b109e200c84b4271385c9e6c1ba6208daaf0b3 Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 14 Mar 2022 13:13:51 +0800 Subject: [PATCH] cluster: fix cannot use exec command when hostname contain '-' (#1794) --- pkg/cluster/manager/exec.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cluster/manager/exec.go b/pkg/cluster/manager/exec.go index 1d67d46301..e4f82d6b40 100644 --- a/pkg/cluster/manager/exec.go +++ b/pkg/cluster/manager/exec.go @@ -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 @@ -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).