Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common SSHPort on e2essh #89784

Merged
merged 1 commit into from Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 2 additions & 7 deletions test/e2e/framework/kubesystem/kubesystem.go
Expand Up @@ -26,11 +26,6 @@ import (
e2essh "k8s.io/kubernetes/test/e2e/framework/ssh"
)

const (
// ssh port
sshPort = "22"
)

// RestartControllerManager restarts the kube-controller-manager.
func RestartControllerManager() error {
// TODO: Make it work for all providers and distros.
Expand All @@ -42,7 +37,7 @@ func RestartControllerManager() error {
}
cmd := "pidof kube-controller-manager | xargs sudo kill"
framework.Logf("Restarting controller-manager via ssh, running: %v", cmd)
result, err := e2essh.SSH(cmd, net.JoinHostPort(framework.GetMasterHost(), sshPort), framework.TestContext.Provider)
result, err := e2essh.SSH(cmd, net.JoinHostPort(framework.GetMasterHost(), e2essh.SSHPort), framework.TestContext.Provider)
if err != nil || result.Code != 0 {
e2essh.LogResult(result)
return fmt.Errorf("couldn't restart controller-manager: %v", err)
Expand All @@ -54,7 +49,7 @@ func RestartControllerManager() error {
func WaitForControllerManagerUp() error {
cmd := "curl http://localhost:" + strconv.Itoa(framework.InsecureKubeControllerManagerPort) + "/healthz"
for start := time.Now(); time.Since(start) < time.Minute; time.Sleep(5 * time.Second) {
result, err := e2essh.SSH(cmd, net.JoinHostPort(framework.GetMasterHost(), sshPort), framework.TestContext.Provider)
result, err := e2essh.SSH(cmd, net.JoinHostPort(framework.GetMasterHost(), e2essh.SSHPort), framework.TestContext.Provider)
if err != nil || result.Code != 0 {
e2essh.LogResult(result)
}
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/framework/ssh/ssh.go
Expand Up @@ -40,8 +40,8 @@ import (
)

const (
// ssh port
sshPort = "22"
// SSHPort is tcp port number of SSH
SSHPort = "22"

// pollNodeInterval is how often to Poll pods.
pollNodeInterval = 2 * time.Second
Expand Down Expand Up @@ -136,7 +136,7 @@ func NodeSSHHosts(c clientset.Interface) ([]string, error) {

sshHosts := make([]string, 0, len(hosts))
for _, h := range hosts {
sshHosts = append(sshHosts, net.JoinHostPort(h, sshPort))
sshHosts = append(sshHosts, net.JoinHostPort(h, SSHPort))
}
return sshHosts, nil
}
Expand All @@ -155,7 +155,7 @@ type Result struct {
// eg: the name returned by framework.GetMasterHost(). This is also not guaranteed to work across
// cloud providers since it involves ssh.
func NodeExec(nodeName, cmd, provider string) (Result, error) {
return SSH(cmd, net.JoinHostPort(nodeName, sshPort), provider)
return SSH(cmd, net.JoinHostPort(nodeName, SSHPort), provider)
}

// SSH synchronously SSHs to a node running on provider and runs cmd. If there
Expand Down Expand Up @@ -330,7 +330,7 @@ func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*Result, er
host := ""
for _, a := range node.Status.Addresses {
if a.Type == v1.NodeExternalIP && a.Address != "" {
host = net.JoinHostPort(a.Address, sshPort)
host = net.JoinHostPort(a.Address, SSHPort)
break
}
}
Expand All @@ -339,7 +339,7 @@ func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*Result, er
// No external IPs were found, let's try to use internal as plan B
for _, a := range node.Status.Addresses {
if a.Type == v1.NodeInternalIP && a.Address != "" {
host = net.JoinHostPort(a.Address, sshPort)
host = net.JoinHostPort(a.Address, SSHPort)
break
}
}
Expand Down
5 changes: 1 addition & 4 deletions test/e2e/network/service.go
Expand Up @@ -87,9 +87,6 @@ const (
// AffinityConfirmCount is the number of needed continuous requests to confirm that
// affinity is enabled.
AffinityConfirmCount = 15

// ssh port
sshPort = "22"
)

var (
Expand Down Expand Up @@ -3587,7 +3584,7 @@ func sshRestartMaster() error {
command = "sudo /etc/init.d/kube-apiserver restart"
}
framework.Logf("Restarting master via ssh, running: %v", command)
result, err := e2essh.SSH(command, net.JoinHostPort(framework.GetMasterHost(), sshPort), framework.TestContext.Provider)
result, err := e2essh.SSH(command, net.JoinHostPort(framework.GetMasterHost(), e2essh.SSHPort), framework.TestContext.Provider)
if err != nil || result.Code != 0 {
e2essh.LogResult(result)
return fmt.Errorf("couldn't restart apiserver: %v", err)
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/storage/flexvolume.go
Expand Up @@ -38,7 +38,6 @@ import (
)

const (
sshPort = "22"
driverDir = "test/e2e/testing-manifests/flexvolume/"
defaultVolumePluginDir = "/usr/libexec/kubernetes/kubelet-plugins/volume/exec"
// TODO: change this and config-test.sh when default flex volume install path is changed for GCI
Expand Down Expand Up @@ -84,7 +83,7 @@ func installFlex(c clientset.Interface, node *v1.Node, vendor, driver, filePath
} else {
masterHostWithPort := framework.GetMasterHost()
hostName := getHostFromHostPort(masterHostWithPort)
host = net.JoinHostPort(hostName, sshPort)
host = net.JoinHostPort(hostName, e2essh.SSHPort)
}

framework.ExpectNoError(err)
Expand Down Expand Up @@ -113,7 +112,7 @@ func uninstallFlex(c clientset.Interface, node *v1.Node, vendor, driver string)
} else {
masterHostWithPort := framework.GetMasterHost()
hostName := getHostFromHostPort(masterHostWithPort)
host = net.JoinHostPort(hostName, sshPort)
host = net.JoinHostPort(hostName, e2essh.SSHPort)
}

if host == "" {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/storage/nfs_persistent_volume-disruptive.go
Expand Up @@ -52,7 +52,7 @@ func checkForControllerManagerHealthy(duration time.Duration) error {
var PID string
cmd := "pidof kube-controller-manager"
for start := time.Now(); time.Since(start) < duration; time.Sleep(5 * time.Second) {
result, err := e2essh.SSH(cmd, net.JoinHostPort(framework.GetMasterHost(), sshPort), framework.TestContext.Provider)
result, err := e2essh.SSH(cmd, net.JoinHostPort(framework.GetMasterHost(), e2essh.SSHPort), framework.TestContext.Provider)
if err != nil {
// We don't necessarily know that it crashed, pipe could just be broken
e2essh.LogResult(result)
Expand Down