Skip to content

Commit

Permalink
fix GetHostArch without use args port (labring#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostloda committed May 6, 2023
1 parent 015f9c5 commit 5feb91b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/apply/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package apply

import (
"fmt"
"net"
"strconv"

"github.com/labring/sealos/pkg/apply/applydrivers"
Expand Down Expand Up @@ -115,17 +116,22 @@ 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{}

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)
Expand Down

0 comments on commit 5feb91b

Please sign in to comment.