Merge pull request #7726 from medyagh/retry_unification
use wait.poll for waiting on default sapull/7735/head
commit
3afa3d6970
|
@ -84,7 +84,8 @@ var dashboardCmd = &cobra.Command{
|
|||
svc := "kubernetes-dashboard"
|
||||
out.ErrT(out.Verifying, "Verifying dashboard health ...")
|
||||
checkSVC := func() error { return service.CheckService(ns, svc) }
|
||||
if err = retry.Expo(checkSVC, 1*time.Second, time.Minute*5); err != nil {
|
||||
// for slow machines or parallels in CI to avoid #7503
|
||||
if err = retry.Expo(checkSVC, 100*time.Microsecond, time.Minute*10); err != nil {
|
||||
exit.WithCodeT(exit.Unavailable, "dashboard service is not running: {{.error}}", out.V{"error": err})
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ var dashboardCmd = &cobra.Command{
|
|||
|
||||
out.ErrT(out.Verifying, "Verifying proxy health ...")
|
||||
chkURL := func() error { return checkURL(url) }
|
||||
if err = retry.Expo(chkURL, 1*time.Second, 3*time.Minute); err != nil {
|
||||
if err = retry.Expo(chkURL, 100*time.Microsecond, 10*time.Minute); err != nil {
|
||||
exit.WithCodeT(exit.Unavailable, "{{.url}} is not accessible: {{.error}}", out.V{"url": url, "error": err})
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ func enableOrDisableAddonInternal(cc *config.ClusterConfig, addon *assets.Addon,
|
|||
return err
|
||||
}
|
||||
|
||||
return retry.Expo(apply, 1*time.Second, time.Second*30)
|
||||
return retry.Expo(apply, 100*time.Microsecond, time.Minute)
|
||||
}
|
||||
|
||||
// enableOrDisableStorageClasses enables or disables storage classes
|
||||
|
|
|
@ -18,36 +18,36 @@ limitations under the License.
|
|||
package kverify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/minikube/pkg/util/retry"
|
||||
kconst "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
|
||||
// WaitForDefaultSA waits for the default service account to be created.
|
||||
func WaitForDefaultSA(cs *kubernetes.Clientset, timeout time.Duration) error {
|
||||
glog.Info("waiting for default service account to be created ...")
|
||||
start := time.Now()
|
||||
saReady := func() error {
|
||||
saReady := func() (bool, error) {
|
||||
// equivalent to manual check of 'kubectl --context profile get serviceaccount default'
|
||||
sas, err := cs.CoreV1().ServiceAccounts("default").List(meta.ListOptions{})
|
||||
if err != nil {
|
||||
glog.Infof("temproary error waiting for default SA: %v", err)
|
||||
return err
|
||||
return false, nil
|
||||
}
|
||||
for _, sa := range sas.Items {
|
||||
if sa.Name == "default" {
|
||||
glog.Infof("found service account: %q", sa.Name)
|
||||
return nil
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("couldn't find default service account")
|
||||
return false, nil
|
||||
}
|
||||
if err := retry.Expo(saReady, 500*time.Millisecond, timeout); err != nil {
|
||||
if err := wait.PollImmediate(kconst.APICallRetryInterval, timeout, saReady); err != nil {
|
||||
return errors.Wrapf(err, "waited %s for SA", time.Since(start))
|
||||
}
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ func (k *Bootstrapper) restartCluster(cfg config.ClusterConfig) error {
|
|||
_, err := k.c.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("%s phase addon all --config %s", baseCmd, conf)))
|
||||
return err
|
||||
}
|
||||
if err = retry.Expo(addonPhase, 1*time.Second, 30*time.Second); err != nil {
|
||||
if err = retry.Expo(addonPhase, 100*time.Microsecond, 30*time.Second); err != nil {
|
||||
glog.Warningf("addon install failed, wil retry: %v", err)
|
||||
return errors.Wrap(err, "addons")
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ func (p *BuildrootProvisioner) Provision(swarmOptions swarm.Options, authOptions
|
|||
return nil
|
||||
}
|
||||
|
||||
err := retry.Expo(configAuth, time.Second, 2*time.Minute)
|
||||
err := retry.Expo(configAuth, 100*time.Microsecond, 2*time.Minute)
|
||||
if err != nil {
|
||||
glog.Infof("Error configuring auth during provisioning %v", err)
|
||||
return err
|
||||
|
|
|
@ -180,7 +180,7 @@ func (p *UbuntuProvisioner) Provision(swarmOptions swarm.Options, authOptions au
|
|||
return nil
|
||||
}
|
||||
|
||||
err := retry.Expo(configAuth, time.Second, 2*time.Minute)
|
||||
err := retry.Expo(configAuth, 100*time.Microsecond, 2*time.Minute)
|
||||
|
||||
if err != nil {
|
||||
glog.Infof("Error configuring auth during provisioning %v", err)
|
||||
|
|
Loading…
Reference in New Issue