Improve readability of ISO download errors + include URL.

This is a separate issue I bumped into while developing the dashboard
PR.
pull/3210/head
Thomas Stromberg 2018-10-03 12:56:54 -07:00
parent 21776a09b5
commit bc2dbe3b08
3 changed files with 6 additions and 3 deletions

View File

@ -217,7 +217,7 @@ func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error
if config.VMDriver != "none" {
if err := config.Downloader.CacheMinikubeISOFromURL(config.MinikubeISO); err != nil {
return nil, errors.Wrap(err, "Error attempting to cache minikube ISO from URL")
return nil, errors.Wrap(err, "unable to cache ISO")
}
}

View File

@ -72,9 +72,9 @@ func (f DefaultDownloader) CacheMinikubeISOFromURL(isoURL string) error {
options.ChecksumHash = crypto.SHA256
}
fmt.Println("Downloading Minikube ISO")
fmt.Printf("Downloading Minikube ISO: %s\n", isoURL)
if err := download.ToFile(isoURL, f.GetISOCacheFilepath(isoURL), options); err != nil {
return errors.Wrap(err, "Error downloading Minikube ISO")
return errors.Wrap(err, "ToFile")
}
return nil

View File

@ -97,14 +97,17 @@ func Retry(attempts int, callback func() error) (err error) {
func RetryAfter(attempts int, callback func() error, d time.Duration) (err error) {
m := MultiError{}
for i := 0; i < attempts; i++ {
glog.V(1).Infof("retry loop %d", i)
err = callback()
if err == nil {
return nil
}
m.Collect(err)
if _, ok := err.(*RetriableError); !ok {
glog.Infof("non-retriable error: %v", err)
return m.ToError()
}
glog.V(2).Infof("sleeping %s", d)
time.Sleep(d)
}
return m.ToError()