enable full linter across the codebase (#9620)

enable linter using golangci-lint across
codebase to run a bunch of linters together,
we shall enable new linters as we fix more
things the codebase.

This PR fixes the first stage of this
cleanup.
This commit is contained in:
Harshavardhana
2020-05-18 09:59:45 -07:00
committed by GitHub
parent 96009975d6
commit 1bc32215b9
39 changed files with 128 additions and 239 deletions

View File

@@ -21,7 +21,6 @@ import (
"context"
"encoding/json"
"io/ioutil"
"math"
"net/http"
"time"
)
@@ -128,23 +127,6 @@ func (adm *AdminClient) StorageInfo(ctx context.Context) (StorageInfo, error) {
return storageInfo, nil
}
type objectHistogramInterval struct {
name string
start, end int64
}
// ObjectsHistogramIntervals contains the list of intervals
// of an histogram analysis of objects sizes.
var ObjectsHistogramIntervals = []objectHistogramInterval{
{"LESS_THAN_1024_B", -1, 1024 - 1},
{"BETWEEN_1024_B_AND_1_MB", 1024, 1024*1024 - 1},
{"BETWEEN_1_MB_AND_10_MB", 1024 * 1024, 1024*1024*10 - 1},
{"BETWEEN_10_MB_AND_64_MB", 1024 * 1024 * 10, 1024*1024*64 - 1},
{"BETWEEN_64_MB_AND_128_MB", 1024 * 1024 * 64, 1024*1024*128 - 1},
{"BETWEEN_128_MB_AND_512_MB", 1024 * 1024 * 128, 1024*1024*512 - 1},
{"GREATER_THAN_512_MB", 1024 * 1024 * 512, math.MaxInt64},
}
// DataUsageInfo represents data usage of an Object API
type DataUsageInfo struct {
// LastUpdate is the timestamp of when the data usage info was last updated.

View File

@@ -20,10 +20,7 @@ package madmin
import (
"context"
"math/rand"
"net"
"net/http"
"net/url"
"strings"
"sync"
"time"
)
@@ -116,37 +113,6 @@ func (adm AdminClient) newRetryTimer(ctx context.Context, maxRetry int, unit tim
return attemptCh
}
// isHTTPReqErrorRetryable - is http requests error retryable, such
// as i/o timeout, connection broken etc..
func isHTTPReqErrorRetryable(err error) bool {
if err == nil {
return false
}
switch e := err.(type) {
case *url.Error:
switch e.Err.(type) {
case *net.DNSError, *net.OpError, net.UnknownNetworkError:
return true
}
if strings.Contains(err.Error(), "Connection closed by foreign host") {
return true
} else if strings.Contains(err.Error(), "net/http: TLS handshake timeout") {
// If error is - tlsHandshakeTimeoutError, retry.
return true
} else if strings.Contains(err.Error(), "i/o timeout") {
// If error is - tcp timeoutError, retry.
return true
} else if strings.Contains(err.Error(), "connection timed out") {
// If err is a net.Dial timeout, retry.
return true
} else if strings.Contains(err.Error(), "net/http: HTTP/1.x transport connection broken") {
// If error is transport connection broken, retry.
return true
}
}
return false
}
// List of AWS S3 error codes which are retryable.
var retryableS3Codes = map[string]struct{}{
"RequestError": {},