diff --git a/pkg/util/manager/task-run.go b/pkg/util/manager/task-run.go index 27775410..c6a5b399 100644 --- a/pkg/util/manager/task-run.go +++ b/pkg/util/manager/task-run.go @@ -14,7 +14,7 @@ import ( const ( DefaultCon = 10 - Timeout = 600 + Timeout = 1800 ) // NodeTask is a task that is specifically tailored to run on a single node. @@ -66,7 +66,7 @@ func (mgr *Manager) RunTaskOnNodes(nodes []kubekeyapi.HostCfg, task NodeTask, pa select { case <-result: case <-time.After(time.Second * Timeout): - fmt.Sprintf("getSSHClient error,SSH-Read-TimeOut,Timeout=%ds", Timeout) + mgr.Logger.Fatalf("Execute task timeout, Timeout=%ds", Timeout) } wg.Done() <-ccons diff --git a/pkg/util/runner/runner.go b/pkg/util/runner/runner.go index 98bfd39a..c20e4db9 100644 --- a/pkg/util/runner/runner.go +++ b/pkg/util/runner/runner.go @@ -6,7 +6,6 @@ import ( ssh2 "github.com/kubesphere/kubekey/pkg/util/ssh" "github.com/pkg/errors" "strings" - "time" ) type Runner struct { @@ -18,8 +17,6 @@ type Runner struct { Index int } -type TemplateVariables map[string]interface{} - func (r *Runner) RunCmd(cmd string) (string, error) { if r.Conn == nil { return "", errors.New("Runner is not tied to an opened SSH connection") @@ -65,36 +62,3 @@ func (r *Runner) ScpFile(src, dst string) error { } return nil } - -// WaitForPod waits for the availability of the given Kubernetes element. -func (r *Runner) WaitForPod(namespace string, name string, timeout time.Duration) error { - cmd := fmt.Sprintf(`sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf -n "%s" get pod "%s" -o jsonpath='{.status.phase}' --ignore-not-found`, namespace, name) - if !r.WaitForCondition(cmd, timeout, IsRunning) { - return errors.Errorf("Timed out while waiting for %s/%s to come up for %v", namespace, name, timeout) - } - - return nil -} - -type validatorFunc func(stdout string) bool - -// IsRunning checks if the given output represents the "Running" status of a Kubernetes pod. -func IsRunning(stdout string) bool { - return strings.ToLower(stdout) == "running" -} - -// WaitForCondition waits for something to be true. -func (r *Runner) WaitForCondition(cmd string, timeout time.Duration, validator validatorFunc) bool { - cutoff := time.Now().Add(timeout) - - for time.Now().Before(cutoff) { - stdout, _ := r.RunCmd(cmd) - if validator(stdout) { - return true - } - - time.Sleep(1 * time.Second) - } - - return false -}