Skip to content

Commit

Permalink
add UnwarpCheckPointExecutor (#2298)
Browse files Browse the repository at this point in the history
  • Loading branch information
KanShiori authored Nov 1, 2023
1 parent 1477739 commit 721b065
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 0 additions & 1 deletion pkg/cluster/api/tidbapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@ func (c *TiDBClient) FinishUpgrade() error {

return err
}

13 changes: 13 additions & 0 deletions pkg/cluster/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cluster/module/wait_for.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 721b065

Please sign in to comment.