Retry for configureAuth on minikube start
Sometimes the docker daemon isn't ready and on a restart and libmachine times out while trying to reach it. This retries when it isn't ready. This fixes timeout problems in our virtualbox integration tests.pull/833/head
parent
dd5bd7bd18
commit
b72efef48d
|
@ -21,6 +21,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
units "github.com/docker/go-units"
|
units "github.com/docker/go-units"
|
||||||
"github.com/docker/machine/libmachine"
|
"github.com/docker/machine/libmachine"
|
||||||
|
@ -89,11 +90,11 @@ func runStart(cmd *cobra.Command, args []string) {
|
||||||
start := func() (err error) {
|
start := func() (err error) {
|
||||||
host, err = cluster.StartHost(api, config)
|
host, err = cluster.StartHost(api, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error starting host: %s. Retrying.\n", err)
|
glog.Errorf("Error starting host: %s.\n\n Retrying.\n", err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err := util.Retry(3, start)
|
err := util.RetryAfter(5, start, 2*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorln("Error starting host: ", err)
|
glog.Errorln("Error starting host: ", err)
|
||||||
cmdUtil.MaybeReportErrorAndExit(err)
|
cmdUtil.MaybeReportErrorAndExit(err)
|
||||||
|
|
|
@ -95,7 +95,7 @@ func StartHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.ConfigureAuth(); err != nil {
|
if err := h.ConfigureAuth(); err != nil {
|
||||||
return nil, errors.Wrap(&util.RetriableError{Err: err}, "Error configuring auth on host")
|
return nil, &util.RetriableError{Err: errors.Wrap(err, "Error configuring auth on host")}
|
||||||
}
|
}
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/auth"
|
"github.com/docker/machine/libmachine/auth"
|
||||||
"github.com/docker/machine/libmachine/drivers"
|
"github.com/docker/machine/libmachine/drivers"
|
||||||
|
@ -29,6 +30,7 @@ import (
|
||||||
"github.com/docker/machine/libmachine/provision"
|
"github.com/docker/machine/libmachine/provision"
|
||||||
"github.com/docker/machine/libmachine/provision/pkgaction"
|
"github.com/docker/machine/libmachine/provision/pkgaction"
|
||||||
"github.com/docker/machine/libmachine/swarm"
|
"github.com/docker/machine/libmachine/swarm"
|
||||||
|
"k8s.io/minikube/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BuildrootProvisioner struct {
|
type BuildrootProvisioner struct {
|
||||||
|
@ -130,7 +132,17 @@ func (p *BuildrootProvisioner) Provision(swarmOptions swarm.Options, authOptions
|
||||||
log.Debugf("set auth options %+v", p.AuthOptions)
|
log.Debugf("set auth options %+v", p.AuthOptions)
|
||||||
|
|
||||||
log.Debugf("setting up certificates")
|
log.Debugf("setting up certificates")
|
||||||
|
|
||||||
|
configureAuth := func() error {
|
||||||
if err := provision.ConfigureAuth(p); err != nil {
|
if err := provision.ConfigureAuth(p); err != nil {
|
||||||
|
return &util.RetriableError{Err: err}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := util.RetryAfter(5, configureAuth, time.Second*10)
|
||||||
|
if err != nil {
|
||||||
|
log.Debugf("Error configuring auth during provisioning %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue