docker.exec takes context

This commit is contained in:
William Banfield
2022-11-29 13:50:39 -05:00
parent b2740d39d8
commit f0f98c8156
3 changed files with 6 additions and 6 deletions

View File

@@ -110,6 +110,6 @@ func ExecComposeVerbose(ctx context.Context, dir string, args ...string) error {
}
// Exec runs a Docker command.
func Exec(args ...string) error {
return exec.Command(context.Background(), append([]string{"docker"}, args...)...)
func Exec(ctx context.Context, args ...string) error {
return exec.Command(ctx, append([]string{"docker"}, args...)...)
}

View File

@@ -72,8 +72,8 @@ func cleanupDir(dir string) error {
if err != nil {
return err
}
err = docker.Exec("run", "--rm", "--entrypoint", "", "-v", fmt.Sprintf("%v:/network", absDir),
"tendermint/e2e-node", "sh", "-c", "rm -rf /network/*/")
err = docker.Exec(context.Background(), "run", "--rm", "--entrypoint", "", "-v", fmt.Sprintf("%v:/network", absDir),
"tendermint/e2e-node", "sh", "-c", "rm -rf /network/*/")
if err != nil {
return err
}

View File

@@ -32,11 +32,11 @@ func PerturbNode(node *e2e.Node, perturbation e2e.Perturbation) (*rpctypes.Resul
switch perturbation {
case e2e.PerturbationDisconnect:
logger.Info("perturb node", "msg", log.NewLazySprintf("Disconnecting node %v...", node.Name))
if err := docker.Exec("network", "disconnect", testnet.Name+"_"+testnet.Name, node.Name); err != nil {
if err := docker.Exec(context.Background(), "network", "disconnect", testnet.Name+"_"+testnet.Name, node.Name) ; err != nil {
return nil, err
}
time.Sleep(10 * time.Second)
if err := docker.Exec("network", "connect", testnet.Name+"_"+testnet.Name, node.Name); err != nil {
if err := docker.Exec(context.Background(), "network", "connect", testnet.Name+"_"+testnet.Name, node.Name) ; err != nil {
return nil, err
}