From 5feb91b71a25eed7ef534e87963a88bc99c2dddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=B4=E8=8E=B2=E6=A6=B4=E8=8E=B2?= <78798447@qq.com> Date: Sat, 6 May 2023 14:32:17 +0800 Subject: [PATCH] fix GetHostArch without use args port (#3042) --- pkg/apply/run.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/apply/run.go b/pkg/apply/run.go index 2b8f60baf3b..f2ff4a186bb 100644 --- a/pkg/apply/run.go +++ b/pkg/apply/run.go @@ -16,6 +16,7 @@ package apply import ( "fmt" + "net" "strconv" "github.com/labring/sealos/pkg/apply/applydrivers" @@ -115,6 +116,7 @@ func (r *ClusterArgs) runArgs(imageList []string, args *RunArgs) error { r.cluster.SetNewImages(imageList) + defaultPort := strconv.Itoa(int(r.cluster.Spec.SSH.Port)) masters := stringsutil.SplitRemoveEmpty(args.Cluster.Masters, ",") nodes := stringsutil.SplitRemoveEmpty(args.Cluster.Nodes, ",") r.hosts = []v2.Host{} @@ -122,10 +124,14 @@ func (r *ClusterArgs) runArgs(imageList []string, args *RunArgs) error { clusterSSH := r.cluster.GetSSH() sshClient := ssh.NewSSHClient(&clusterSSH, true) if len(masters) > 0 { - r.setHostWithIpsPort(masters, []string{v2.MASTER, GetHostArch(sshClient, masters[0])}) + host, port := iputils.GetHostIPAndPortOrDefault(masters[0], defaultPort) + master0addr := net.JoinHostPort(host, port) + r.setHostWithIpsPort(masters, []string{v2.MASTER, GetHostArch(sshClient, master0addr)}) } if len(nodes) > 0 { - r.setHostWithIpsPort(nodes, []string{v2.NODE, GetHostArch(sshClient, nodes[0])}) + host, port := iputils.GetHostIPAndPortOrDefault(nodes[0], defaultPort) + node0addr := net.JoinHostPort(host, port) + r.setHostWithIpsPort(nodes, []string{v2.NODE, GetHostArch(sshClient, node0addr)}) } r.cluster.Spec.Hosts = append(r.cluster.Spec.Hosts, r.hosts...) logger.Debug("cluster info: %v", r.cluster)