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
Matt Rickard 2016-11-16 11:50:08 -08:00
parent dd5bd7bd18
commit b72efef48d
3 changed files with 17 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import (
"os"
"strconv"
"strings"
"time"
units "github.com/docker/go-units"
"github.com/docker/machine/libmachine"
@ -89,11 +90,11 @@ func runStart(cmd *cobra.Command, args []string) {
start := func() (err error) {
host, err = cluster.StartHost(api, config)
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
}
err := util.Retry(3, start)
err := util.RetryAfter(5, start, 2*time.Second)
if err != nil {
glog.Errorln("Error starting host: ", err)
cmdUtil.MaybeReportErrorAndExit(err)

View File

@ -95,7 +95,7 @@ func StartHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
}
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
}

View File

@ -21,6 +21,7 @@ import (
"fmt"
"path"
"text/template"
"time"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/drivers"
@ -29,6 +30,7 @@ import (
"github.com/docker/machine/libmachine/provision"
"github.com/docker/machine/libmachine/provision/pkgaction"
"github.com/docker/machine/libmachine/swarm"
"k8s.io/minikube/pkg/util"
)
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("setting up certificates")
if err := provision.ConfigureAuth(p); err != nil {
configureAuth := func() error {
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
}