diff --git a/cli/backup.go b/cli/backup.go index 3ff32cff..683aa516 100644 --- a/cli/backup.go +++ b/cli/backup.go @@ -259,7 +259,7 @@ func (n Nexus3) StoreArtifactsOnDisk(regex string) error { // unless the metadata.xml is opened first if !(filepath.Ext(url) == ".md5" || filepath.Ext(url) == ".sha1") { if err := n.downloadArtifact(downloadURL); err != nil { - return err + log.Error(err) } } } diff --git a/cli/req.go b/cli/req.go index d6499f86..a13c65cc 100644 --- a/cli/req.go +++ b/cli/req.go @@ -3,6 +3,7 @@ package cli import ( "errors" "fmt" + "github.com/hashicorp/go-retryablehttp" "io/ioutil" "net/http" "strconv" @@ -40,7 +41,11 @@ func (n Nexus3) request(url string) ([]byte, string, error) { } func (n Nexus3) response(req *http.Request) ([]byte, string, error) { - resp, err := http.DefaultClient.Do(req) + retryClient := retryablehttp.NewClient() + retryClient.RetryMax = 5 + retryClient.Logger = nil + standardClient := retryClient.StandardClient() + resp, err := standardClient.Do(req) if err != nil { return nil, "", err } diff --git a/go.mod b/go.mod index a57743a7..ed5882d2 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/fatih/color v1.7.0 // indirect github.com/frankban/quicktest v1.4.1 // indirect github.com/golang/snappy v0.0.1 // indirect + github.com/hashicorp/go-retryablehttp v0.6.6 github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/mattn/go-colorable v0.1.1 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect @@ -22,6 +23,7 @@ require ( github.com/sirupsen/logrus v1.4.2 github.com/spf13/cobra v0.0.3 github.com/spf13/viper v1.3.2 + github.com/stretchr/testify v1.2.2 github.com/svenfuchs/jq v0.0.0-20180603193138-b038733a5990 github.com/thedevsaddam/gojsonq v2.2.0+incompatible github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect diff --git a/go.sum b/go.sum index 816690c8..998ac4de 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,11 @@ github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM= +github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=