diff --git a/pkg/cmd/grafana-cli/commands/install_command.go b/pkg/cmd/grafana-cli/commands/install_command.go index 773d5958f4c..070c0aa77c3 100644 --- a/pkg/cmd/grafana-cli/commands/install_command.go +++ b/pkg/cmd/grafana-cli/commands/install_command.go @@ -111,7 +111,21 @@ func RemoveGitBuildFromname(pluginname, filename string) string { return r.ReplaceAllString(filename, pluginname+"/") } +var retryCount = 0 + func downloadFile(pluginName, filepath, url string) (err error) { + defer func() { + if r := recover(); r != nil { + retryCount++ + if retryCount == 1 { + log.Debug("\nFailed downloading. Will retry once.\n") + downloadFile(pluginName, filepath, url) + } else { + panic(r) + } + } + }() + resp, err := http.Get(url) if err != nil { return err @@ -122,12 +136,6 @@ func downloadFile(pluginName, filepath, url string) (err error) { if err != nil { return err } - log.Infof("Got statuscode %s from %s\n", resp.Status, url) - - if resp.StatusCode == 302 || resp.StatusCode == 301 { - str, _ := ioutil.ReadAll(resp.Body) - log.Info("body %s\n\n", string(str)) - } r, err := zip.NewReader(bytes.NewReader(body), resp.ContentLength) if err != nil {