From d57fdd909fdd965349f5c168ee27caa10aa0c867 Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Sat, 30 May 2015 16:53:34 -0700 Subject: [PATCH] remove retry capability --- cmd-access.go | 7 ------- cmd-mb.go | 7 ------- cmd-options.go | 6 ------ cmd_test.go | 32 -------------------------------- common-methods.go | 22 ---------------------- docs/index.md | 1 - globals.go | 7 +++---- main.go | 1 - pkg/console/console.go | 6 ------ pkg/console/themes.go | 3 --- 10 files changed, 3 insertions(+), 89 deletions(-) diff --git a/cmd-access.go b/cmd-access.go index 64fde36f..ba144188 100644 --- a/cmd-access.go +++ b/cmd-access.go @@ -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) diff --git a/cmd-mb.go b/cmd-mb.go index 00439a11..00e2c8bc 100644 --- a/cmd-mb.go +++ b/cmd-mb.go @@ -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) diff --git a/cmd-options.go b/cmd-options.go index 3eab1a9d..268e245b 100644 --- a/cmd-options.go +++ b/cmd-options.go @@ -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 } ) diff --git a/cmd_test.go b/cmd_test.go index 4b3bb71d..0350e561 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -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-") diff --git a/common-methods.go b/common-methods.go index 4567eda2..40b81cf0 100644 --- a/common-methods.go +++ b/common-methods.go @@ -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 -} diff --git a/docs/index.md b/docs/index.md index 9d7906d4..509e72cc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 ``` diff --git a/globals.go b/globals.go index b72f205c..c167ba69 100644 --- a/globals.go +++ b/globals.go @@ -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" ) diff --git a/main.go b/main.go index 0e3e7a3d..292881e4 100644 --- a/main.go +++ b/main.go @@ -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() diff --git a/pkg/console/console.go b/pkg/console/console.go index ff7fe5a9..ebf6681e 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -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 ( diff --git a/pkg/console/themes.go b/pkg/console/themes.go index 2a26cac2..132bba2e 100644 --- a/pkg/console/themes.go +++ b/pkg/console/themes.go @@ -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()),