diff --git a/pkg/cluster/api/tidbapi.go b/pkg/cluster/api/tidbapi.go index ddb3a36403..793ba16656 100644 --- a/pkg/cluster/api/tidbapi.go +++ b/pkg/cluster/api/tidbapi.go @@ -75,4 +75,3 @@ func (c *TiDBClient) FinishUpgrade() error { return err } - diff --git a/pkg/cluster/executor/executor.go b/pkg/cluster/executor/executor.go index a2c2f20aab..8cc867a991 100644 --- a/pkg/cluster/executor/executor.go +++ b/pkg/cluster/executor/executor.go @@ -118,6 +118,19 @@ func New(etype SSHType, sudo bool, c SSHConfig) (ctxt.Executor, error) { return &CheckPointExecutor{executor, &c}, nil } +// UnwarpCheckPointExecutor unwarp the CheckPointExecutor and return the real executor +// +// Sometimes we just want to get the output of a command, and the CheckPointExecutor will +// always cache the output, it will be a problem when we want to get the real output. +func UnwarpCheckPointExecutor(e ctxt.Executor) ctxt.Executor { + switch e := e.(type) { + case *CheckPointExecutor: + return e.Executor + default: + return e + } +} + func checkLocalIP(ip string) error { ifaces, err := net.Interfaces() if err != nil { diff --git a/pkg/cluster/module/wait_for.go b/pkg/cluster/module/wait_for.go index 8a59104e1b..757b0f8fae 100644 --- a/pkg/cluster/module/wait_for.go +++ b/pkg/cluster/module/wait_for.go @@ -21,6 +21,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/cluster/ctxt" + "github.com/pingcap/tiup/pkg/cluster/executor" "github.com/pingcap/tiup/pkg/utils" "go.uber.org/zap" ) @@ -71,7 +72,7 @@ func (w *WaitFor) Execute(ctx context.Context, e ctxt.Executor) (err error) { } if err := utils.Retry(func() error { // only listing TCP ports - stdout, _, err := e.Execute(ctx, "ss -ltn", false) + stdout, _, err := executor.UnwarpCheckPointExecutor(e).Execute(ctx, "ss -ltn", false) if err == nil { switch w.c.State { case "started":