container: Fix implementation since the vendor package updated
This commit is contained in:
parent
a325f5f46b
commit
4a8dc84a17
|
@ -34,7 +34,7 @@ import (
|
|||
"github.com/docker/docker/client"
|
||||
"github.com/docker/go-connections/nat"
|
||||
|
||||
istcommon "github.com/getamis/istanbul-tools/common"
|
||||
"github.com/getamis/istanbul-tools/common"
|
||||
)
|
||||
|
||||
//TODO: refactor this with ethereum options?
|
||||
|
@ -196,7 +196,7 @@ func (ct *constellation) Image() string {
|
|||
|
||||
func (ct *constellation) GenerateKey() (localWorkDir string, err error) {
|
||||
// Generate empty password file
|
||||
ct.localWorkDir, err = istcommon.GenerateRandomDir()
|
||||
ct.localWorkDir, err = common.GenerateRandomDir()
|
||||
if err != nil {
|
||||
log.Printf("Failed to generate working dir, err: :%v\n", err)
|
||||
return "", err
|
||||
|
@ -247,10 +247,8 @@ func (ct *constellation) GenerateKey() (localWorkDir string, err error) {
|
|||
hiresp.Conn.Write([]byte("")) //Empty password
|
||||
|
||||
// Wait container
|
||||
resC, errC := ct.client.ContainerWait(context.Background(), id, container.WaitConditionNotRunning)
|
||||
select {
|
||||
case <-resC:
|
||||
case <-errC:
|
||||
_, err = ct.client.ContainerWait(context.Background(), id)
|
||||
if err != nil {
|
||||
log.Printf("Failed to wait container, err: %v\n", err)
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ import (
|
|||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
func (eth *ethereum) Image() string {
|
||||
|
@ -35,7 +38,10 @@ func (eth *ethereum) ContainerID() string {
|
|||
|
||||
func (eth *ethereum) Host() string {
|
||||
var host string
|
||||
daemonHost := eth.dockerClient.DaemonHost()
|
||||
daemonHost := os.Getenv("DOCKER_HOST")
|
||||
if daemonHost == "" {
|
||||
daemonHost = client.DefaultDockerHost
|
||||
}
|
||||
url, err := url.Parse(daemonHost)
|
||||
if err != nil {
|
||||
log.Printf("Failed to parse daemon host, err: %v", err)
|
||||
|
|
|
@ -49,7 +49,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
healthCheckRetryCount = 20
|
||||
healthCheckRetryCount = 30
|
||||
healthCheckRetryDelay = 2 * time.Second
|
||||
)
|
||||
|
||||
|
@ -187,10 +187,8 @@ func (eth *ethereum) Init(genesisFile string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
resC, errC := eth.dockerClient.ContainerWait(context.Background(), id, container.WaitConditionNotRunning)
|
||||
select {
|
||||
case <-resC:
|
||||
case <-errC:
|
||||
_, err = eth.dockerClient.ContainerWait(context.Background(), id)
|
||||
if err != nil {
|
||||
log.Printf("Failed to wait container, err: %v", err)
|
||||
return err
|
||||
}
|
||||
|
@ -337,8 +335,8 @@ func (eth *ethereum) Stop() error {
|
|||
func (eth *ethereum) Wait(t time.Duration) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), t)
|
||||
defer cancel()
|
||||
_, errCh := eth.dockerClient.ContainerWait(ctx, eth.containerID, "")
|
||||
return <-errCh
|
||||
_, err := eth.dockerClient.ContainerWait(ctx, eth.containerID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (eth *ethereum) Running() bool {
|
||||
|
|
Loading…
Reference in New Issue