Merge pull request #718 from abperiasamy/remove-retry

remove retry capability
This commit is contained in:
Anand Babu (AB) Periasamy
2015-05-30 16:55:16 -07:00
10 changed files with 3 additions and 89 deletions
-7
View File
@@ -19,7 +19,6 @@ package main
import (
"errors"
"fmt"
"time"
"github.com/minio/cli"
"github.com/minio/mc/pkg/client"
@@ -94,12 +93,6 @@ func doUpdateAccessCmd(targetURL, targetACL string, targetConfig *hostConfig) (s
func doUpdateAccess(clnt client.Client, targetURL, targetACL string) (string, error) {
err := clnt.SetBucketACL(targetACL)
for i := 0; i < globalMaxRetryFlag && err != nil && isValidRetry(err); i++ {
console.Retry("Retrying ...", i)
// Progressively longer delays
time.Sleep(time.Duration(i*i) * time.Second)
err = clnt.SetBucketACL(targetACL)
}
if err != nil {
msg := fmt.Sprintf("Failed to add bucket access policy for URL ‘%s’", targetURL)
return msg, iodine.New(err, nil)
-7
View File
@@ -19,7 +19,6 @@ package main
import (
"errors"
"fmt"
"time"
"github.com/minio/cli"
"github.com/minio/mc/pkg/client"
@@ -97,12 +96,6 @@ func doMakeBucketCmd(targetURL string, targetConfig *hostConfig) (string, error)
// doMakeBucket - wrapper around MakeBucket() API
func doMakeBucket(clnt client.Client, targetURL string) (string, error) {
err := clnt.MakeBucket()
for i := 0; i < globalMaxRetryFlag && err != nil && isValidRetry(err); i++ {
console.Retry("Retrying ...", i)
// Progressively longer delays
time.Sleep(time.Duration(i*i) * time.Second)
err = clnt.MakeBucket()
}
if err != nil {
msg := fmt.Sprintf("Failed to create bucket for URL ‘%s’", targetURL)
return msg, iodine.New(err, nil)
-6
View File
@@ -348,7 +348,6 @@ var commands = []cli.Command{
// --json Enable json formatted output
// --debug Enable HTTP tracing
// --quiet, -q Supress chatty console output
// --retry "5" Number of retry count
// --version, -v print the version
//
var (
@@ -379,11 +378,6 @@ var (
Name: "quiet, q",
Usage: "Supress chatty console output",
},
cli.IntFlag{
Name: "retry",
Usage: "Number of retry count",
Value: 5,
},
// Add your new flags starting here
}
)
-32
View File
@@ -26,13 +26,10 @@ import (
"runtime"
"testing"
"errors"
"net"
"net/http/httptest"
. "github.com/minio/check"
"github.com/minio/mc/pkg/quick"
"github.com/minio/minio/pkg/iodine"
)
func Test(t *testing.T) { TestingT(t) }
@@ -240,35 +237,6 @@ func (ta *testAddr) String() string {
return "testAddr"
}
func (s *CmdTestSuite) TestIsValidRetry(c *C) {
opError := &net.OpError{
Op: "read",
Net: "net",
Addr: &testAddr{},
Err: errors.New("Op Error"),
}
c.Assert(isValidRetry(nil), Equals, false)
c.Assert(isValidRetry(errors.New("hello")), Equals, false)
c.Assert(isValidRetry(iodine.New(errors.New("hello"), nil)), Equals, false)
c.Assert(isValidRetry(&net.DNSError{}), Equals, true)
c.Assert(isValidRetry(iodine.New(&net.DNSError{}, nil)), Equals, true)
// op error read
c.Assert(isValidRetry(opError), Equals, true)
c.Assert(isValidRetry(iodine.New(opError, nil)), Equals, true)
// op error write
opError.Op = "write"
c.Assert(isValidRetry(opError), Equals, true)
c.Assert(isValidRetry(iodine.New(opError, nil)), Equals, true)
// op error dial
opError.Op = "dial"
c.Assert(isValidRetry(opError), Equals, true)
c.Assert(isValidRetry(iodine.New(opError, nil)), Equals, true)
// op error foo
opError.Op = "foo"
c.Assert(isValidRetry(opError), Equals, false)
c.Assert(isValidRetry(iodine.New(opError, nil)), Equals, false)
}
func (s *CmdTestSuite) TestCommonMethods(c *C) {
/// filesystem
root, err := ioutil.TempDir(os.TempDir(), "cmd-")
-22
View File
@@ -18,7 +18,6 @@ package main
import (
"io"
"net"
"os"
"runtime"
@@ -141,24 +140,3 @@ func target2Client(targetURL string) (client.Client, error) {
}
return targetClient, nil
}
// isValidRetry - check if we should retry for the given error sequence
func isValidRetry(err error) bool {
err = iodine.New(err, nil)
if err == nil {
return false
}
// DNSError, Network Operation error
switch e := iodine.ToError(err).(type) {
case *net.AddrError:
return true
case *net.DNSError:
return true
case *net.OpError:
switch e.Op {
case "read", "write", "dial":
return true
}
}
return false
}
-1
View File
@@ -38,7 +38,6 @@ GLOBAL FLAGS:
--theme "minimal" Choose a console theme from this list [*minimal*, nocolor, white]
--debug Enable HTTP tracing
--quiet, -q Supress chatty console output
--retry "5" Number of retry count
--version, -v print the version
```
+3 -4
View File
@@ -18,10 +18,9 @@
package main
var (
globalDebugFlag = false // Debug flag set via command line
globalQuietFlag = false // Quiet flag set via command line
globalMaxRetryFlag = 5 // Maximum number of retries
globalJSONFlag = false // Json flag set via command line
globalDebugFlag = false // Debug flag set via command line
globalQuietFlag = false // Quiet flag set via command line
globalJSONFlag = false // Json flag set via command line
mcCurrentConfigVersion = "1.0.0"
)
-1
View File
@@ -108,7 +108,6 @@ func main() {
app.Before = func(ctx *cli.Context) error {
globalQuietFlag = ctx.GlobalBool("quiet")
globalDebugFlag = ctx.GlobalBool("debug")
globalMaxRetryFlag = ctx.GlobalInt("retry")
globalJSONFlag = ctx.GlobalBool("json")
if globalDebugFlag {
app.ExtraInfo = getSystemData()
-6
View File
@@ -46,7 +46,6 @@ type Theme struct {
Time *color.Color
File *color.Color
Dir *color.Color
Retry *color.Color
JSON *color.Color
Bar *color.Color
Print *color.Color
@@ -324,11 +323,6 @@ var (
File = themesDB[currThemeName].File.SprintfFunc()
// Dir helper to print Dir theme
Dir = themesDB[currThemeName].Dir.SprintfFunc()
// Retry prints a retry message
Retry = func(a ...interface{}) {
println(themesDB[currThemeName].Retry, a...)
}
)
var (
-3
View File
@@ -28,7 +28,6 @@ var MiniTheme = Theme{
Dir: (color.New(color.FgCyan, color.Bold)),
Size: (color.New(color.FgYellow)),
Time: (color.New(color.FgGreen)),
Retry: (color.New(color.FgMagenta, color.Bold)),
JSON: (color.New(color.FgWhite, color.Italic)),
Bar: (color.New(color.FgGreen, color.Bold)),
Print: (color.New()),
@@ -44,7 +43,6 @@ var WhiteTheme = Theme{
Dir: (color.New(color.FgWhite, color.Bold)),
Size: (color.New(color.FgWhite, color.Bold)),
Time: (color.New(color.FgWhite, color.Bold)),
Retry: (color.New(color.FgWhite, color.Bold)),
JSON: (color.New(color.FgWhite, color.Bold, color.Italic)),
Bar: (color.New(color.FgWhite, color.Bold)),
Print: (color.New()),
@@ -60,7 +58,6 @@ var NoColorTheme = Theme{
Dir: (color.New()),
Size: (color.New()),
Time: (color.New()),
Retry: (color.New()),
JSON: (color.New()),
Bar: (color.New()),
Print: (color.New()),