mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #75923 from SataQiu/fix-golint-ssh-size-20190331
Fix golint failures of e2e/framework/ssh.go, e2e/framework/size.go
This commit is contained in:
commit
d0c0883a9a
@ -26,6 +26,7 @@ const (
|
|||||||
resizeNodeNotReadyTimeout = 2 * time.Minute
|
resizeNodeNotReadyTimeout = 2 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ResizeGroup resizes an instance group
|
||||||
func ResizeGroup(group string, size int32) error {
|
func ResizeGroup(group string, size int32) error {
|
||||||
if TestContext.ReportDir != "" {
|
if TestContext.ReportDir != "" {
|
||||||
CoreDump(TestContext.ReportDir)
|
CoreDump(TestContext.ReportDir)
|
||||||
@ -34,14 +35,17 @@ func ResizeGroup(group string, size int32) error {
|
|||||||
return TestContext.CloudConfig.Provider.ResizeGroup(group, size)
|
return TestContext.CloudConfig.Provider.ResizeGroup(group, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGroupNodes returns a node name for the specified node group
|
||||||
func GetGroupNodes(group string) ([]string, error) {
|
func GetGroupNodes(group string) ([]string, error) {
|
||||||
return TestContext.CloudConfig.Provider.GetGroupNodes(group)
|
return TestContext.CloudConfig.Provider.GetGroupNodes(group)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupSize returns the size of an instance group
|
||||||
func GroupSize(group string) (int, error) {
|
func GroupSize(group string) (int, error) {
|
||||||
return TestContext.CloudConfig.Provider.GroupSize(group)
|
return TestContext.CloudConfig.Provider.GroupSize(group)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WaitForGroupSize waits for node instance group reached the desired size
|
||||||
func WaitForGroupSize(group string, size int32) error {
|
func WaitForGroupSize(group string, size int32) error {
|
||||||
timeout := 30 * time.Minute
|
timeout := 30 * time.Minute
|
||||||
for start := time.Now(); time.Since(start) < timeout; time.Sleep(20 * time.Second) {
|
for start := time.Now(); time.Since(start) < timeout; time.Sleep(20 * time.Second) {
|
||||||
|
@ -111,6 +111,7 @@ func NodeSSHHosts(c clientset.Interface) ([]string, error) {
|
|||||||
return sshHosts, nil
|
return sshHosts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SSHResult holds the execution result of SSH command
|
||||||
type SSHResult struct {
|
type SSHResult struct {
|
||||||
User string
|
User string
|
||||||
Host string
|
Host string
|
||||||
@ -230,6 +231,7 @@ func RunSSHCommandViaBastion(cmd, user, bastion, host string, signer ssh.Signer)
|
|||||||
return bout.String(), berr.String(), code, err
|
return bout.String(), berr.String(), code, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LogSSHResult records SSHResult log
|
||||||
func LogSSHResult(result SSHResult) {
|
func LogSSHResult(result SSHResult) {
|
||||||
remote := fmt.Sprintf("%s@%s", result.User, result.Host)
|
remote := fmt.Sprintf("%s@%s", result.User, result.Host)
|
||||||
Logf("ssh %s: command: %s", remote, result.Cmd)
|
Logf("ssh %s: command: %s", remote, result.Cmd)
|
||||||
@ -238,6 +240,7 @@ func LogSSHResult(result SSHResult) {
|
|||||||
Logf("ssh %s: exit code: %d", remote, result.Code)
|
Logf("ssh %s: exit code: %d", remote, result.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IssueSSHCommandWithResult tries to execute a SSH command and returns the execution result
|
||||||
func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*SSHResult, error) {
|
func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*SSHResult, error) {
|
||||||
Logf("Getting external IP address for %s", node.Name)
|
Logf("Getting external IP address for %s", node.Name)
|
||||||
host := ""
|
host := ""
|
||||||
@ -274,6 +277,7 @@ func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*SSHResult,
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IssueSSHCommand tries to execute a SSH command
|
||||||
func IssueSSHCommand(cmd, provider string, node *v1.Node) error {
|
func IssueSSHCommand(cmd, provider string, node *v1.Node) error {
|
||||||
_, err := IssueSSHCommandWithResult(cmd, provider, node)
|
_, err := IssueSSHCommandWithResult(cmd, provider, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user