mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
logs: Do not log common successful errors. (#3340)
Errors like `BucketNotFound`, `BucketExists` shouldn't be logged. Fixes #3229
This commit is contained in:
parent
c667d20dfc
commit
d711ff454e
@ -486,6 +486,7 @@ func migrateV8ToV9() error {
|
||||
srvConfig.Region = "us-east-1"
|
||||
}
|
||||
srvConfig.Logger.Console = cv8.Logger.Console
|
||||
srvConfig.Logger.Console.Level = "error"
|
||||
srvConfig.Logger.File = cv8.Logger.File
|
||||
srvConfig.Logger.Syslog = cv8.Logger.Syslog
|
||||
|
||||
|
@ -54,7 +54,7 @@ func initConfig() (bool, error) {
|
||||
// Enable console logger by default on a fresh run.
|
||||
srvCfg.Logger.Console = consoleLogger{
|
||||
Enable: true,
|
||||
Level: "fatal",
|
||||
Level: "error",
|
||||
}
|
||||
|
||||
// Make sure to initialize notification configs.
|
||||
|
@ -41,7 +41,7 @@ type debugLockInfo struct {
|
||||
// "RLock" or "WLock".
|
||||
lType lockType
|
||||
// Contains the trace of the function which invoked the lock, obtained from runtime.
|
||||
lockOrigin string
|
||||
lockSource string
|
||||
// Status can be running/ready/blocked.
|
||||
status statusType
|
||||
// Time info of the since how long the status holds true.
|
||||
@ -80,12 +80,12 @@ type LockInfoOriginNotFound struct {
|
||||
volume string
|
||||
path string
|
||||
opsID string
|
||||
lockOrigin string
|
||||
lockSource string
|
||||
}
|
||||
|
||||
func (l LockInfoOriginNotFound) Error() string {
|
||||
return fmt.Sprintf("No lock state stored for the lock origined at \"%s\", for <volume> %s, <path> %s, <opsID> %s",
|
||||
l.lockOrigin, l.volume, l.path, l.opsID)
|
||||
l.lockSource, l.volume, l.path, l.opsID)
|
||||
}
|
||||
|
||||
// LockInfoVolPathMissing - Error interface. Returned when the info the
|
||||
@ -130,13 +130,13 @@ func (n *nsLockMap) initLockInfoForVolumePath(param nsParam) {
|
||||
}
|
||||
|
||||
// Change the state of the lock from Blocked to Running.
|
||||
func (n *nsLockMap) statusBlockedToRunning(param nsParam, lockOrigin, opsID string, readLock bool) error {
|
||||
func (n *nsLockMap) statusBlockedToRunning(param nsParam, lockSource, opsID string, readLock bool) error {
|
||||
// This operation is not executed under the scope nsLockMap.mutex.Lock(), lock has to be explicitly held here.
|
||||
n.lockMapMutex.Lock()
|
||||
defer n.lockMapMutex.Unlock()
|
||||
// new state info to be set for the lock.
|
||||
newLockInfo := debugLockInfo{
|
||||
lockOrigin: lockOrigin,
|
||||
lockSource: lockSource,
|
||||
status: runningStatus,
|
||||
since: time.Now().UTC(),
|
||||
}
|
||||
@ -165,9 +165,9 @@ func (n *nsLockMap) statusBlockedToRunning(param nsParam, lockOrigin, opsID stri
|
||||
// If not return `LockInfoOpsIDNotFound`.
|
||||
return traceError(LockInfoOpsIDNotFound{param.volume, param.path, opsID})
|
||||
}
|
||||
// The entry for the lock origined at `lockOrigin` should already exist. If not return `LockInfoOriginNotFound`.
|
||||
if lockInfo.lockOrigin != lockOrigin {
|
||||
return traceError(LockInfoOriginNotFound{param.volume, param.path, opsID, lockOrigin})
|
||||
// The entry for the lock origined at `lockSource` should already exist. If not return `LockInfoOriginNotFound`.
|
||||
if lockInfo.lockSource != lockSource {
|
||||
return traceError(LockInfoOriginNotFound{param.volume, param.path, opsID, lockSource})
|
||||
}
|
||||
// Status of the lock should already be set to "Blocked". If not return `LockInfoStateNotBlocked`.
|
||||
if lockInfo.status != blockedStatus {
|
||||
@ -186,9 +186,9 @@ func (n *nsLockMap) statusBlockedToRunning(param nsParam, lockOrigin, opsID stri
|
||||
}
|
||||
|
||||
// Change the state of the lock from Ready to Blocked.
|
||||
func (n *nsLockMap) statusNoneToBlocked(param nsParam, lockOrigin, opsID string, readLock bool) error {
|
||||
func (n *nsLockMap) statusNoneToBlocked(param nsParam, lockSource, opsID string, readLock bool) error {
|
||||
newLockInfo := debugLockInfo{
|
||||
lockOrigin: lockOrigin,
|
||||
lockSource: lockSource,
|
||||
status: blockedStatus,
|
||||
since: time.Now().UTC(),
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
type lockStateCase struct {
|
||||
volume string
|
||||
path string
|
||||
lockOrigin string
|
||||
lockSource string
|
||||
opsID string
|
||||
readLock bool // lock type.
|
||||
setBlocked bool // initialize the initial state to blocked.
|
||||
@ -206,8 +206,8 @@ func verifyLockState(l lockStateCase, t *testing.T, testNum int) {
|
||||
}
|
||||
|
||||
// // validating the lock origin.
|
||||
// if l.lockOrigin != lockInfo.lockOrigin {
|
||||
// t.Fatalf("Test %d: Expected the lock origin info to be \"%s\", but got \"%s\"", testNum, l.lockOrigin, lockInfo.lockOrigin)
|
||||
// if l.lockSource != lockInfo.lockSource {
|
||||
// t.Fatalf("Test %d: Expected the lock origin info to be \"%s\", but got \"%s\"", testNum, l.lockSource, lockInfo.lockSource)
|
||||
// }
|
||||
// validating the status of the lock.
|
||||
if lockInfo.status != l.expectedLockStatus {
|
||||
@ -248,7 +248,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
testCases := []struct {
|
||||
volume string
|
||||
path string
|
||||
lockOrigin string
|
||||
lockSource string
|
||||
opsID string
|
||||
readLock bool // Read lock type.
|
||||
setBlocked bool // Initialize the initial state to blocked.
|
||||
@ -258,7 +258,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "abcd1234",
|
||||
readLock: true,
|
||||
setBlocked: true,
|
||||
@ -271,7 +271,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object-2",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "abcd1234",
|
||||
readLock: false,
|
||||
setBlocked: false,
|
||||
@ -283,7 +283,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "ops-Id-not-registered",
|
||||
readLock: true,
|
||||
setBlocked: false,
|
||||
@ -295,7 +295,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "Bad Origin",
|
||||
lockSource: "Bad Origin",
|
||||
opsID: "abcd1234",
|
||||
readLock: true,
|
||||
setBlocked: false,
|
||||
@ -307,7 +307,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "abcd1234",
|
||||
readLock: false,
|
||||
setBlocked: true,
|
||||
@ -319,7 +319,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
param := nsParam{testCases[0].volume, testCases[0].path}
|
||||
// Testing before the initialization done.
|
||||
// Since the data structures for
|
||||
actualErr := nsMutex.statusBlockedToRunning(param, testCases[0].lockOrigin,
|
||||
actualErr := nsMutex.statusBlockedToRunning(param, testCases[0].lockSource,
|
||||
testCases[0].opsID, testCases[0].readLock)
|
||||
|
||||
expectedErr := LockInfoVolPathMissing{testCases[0].volume, testCases[0].path}
|
||||
@ -334,7 +334,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
}
|
||||
// Entry for <volume, path> pair is set to nil. Should fail with `errLockNotInitialized`.
|
||||
nsMutex.debugLockMap[param] = nil
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCases[0].lockOrigin,
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCases[0].lockSource,
|
||||
testCases[0].opsID, testCases[0].readLock)
|
||||
|
||||
if errorCause(actualErr) != errLockNotInitialized {
|
||||
@ -349,7 +349,7 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
running: 0,
|
||||
}
|
||||
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCases[0].lockOrigin,
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCases[0].lockSource,
|
||||
testCases[0].opsID, testCases[0].readLock)
|
||||
|
||||
expectedOpsErr := LockInfoOpsIDNotFound{testCases[0].volume, testCases[0].path, testCases[0].opsID}
|
||||
@ -369,12 +369,12 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
// Setting the status of the lock to be "Running".
|
||||
// The initial state of the lock should set to "Blocked", otherwise its not possible to change the state from "Blocked" -> "Running".
|
||||
nsMutex.debugLockMap[param].lockInfo[testCases[0].opsID] = debugLockInfo{
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
status: "Running", // State set to "Running". Should fail with `LockInfoStateNotBlocked`.
|
||||
since: time.Now().UTC(),
|
||||
}
|
||||
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCases[0].lockOrigin,
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCases[0].lockSource,
|
||||
testCases[0].opsID, testCases[0].readLock)
|
||||
|
||||
expectedBlockErr := LockInfoStateNotBlocked{testCases[0].volume, testCases[0].path, testCases[0].opsID}
|
||||
@ -391,14 +391,14 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
// status of the lock to be set to "Blocked", before setting Blocked->Running.
|
||||
if testCase.setBlocked {
|
||||
nsMutex.lockMapMutex.Lock()
|
||||
err := nsMutex.statusNoneToBlocked(param, testCase.lockOrigin, testCase.opsID, testCase.readLock)
|
||||
err := nsMutex.statusNoneToBlocked(param, testCase.lockSource, testCase.opsID, testCase.readLock)
|
||||
if err != nil {
|
||||
t.Fatalf("Test %d: Initializing the initial state to Blocked failed <ERROR> %s", i+1, err)
|
||||
}
|
||||
nsMutex.lockMapMutex.Unlock()
|
||||
}
|
||||
// invoking the method under test.
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCase.lockOrigin, testCase.opsID, testCase.readLock)
|
||||
actualErr = nsMutex.statusBlockedToRunning(param, testCase.lockSource, testCase.opsID, testCase.readLock)
|
||||
if errorCause(actualErr) != testCase.expectedErr {
|
||||
t.Fatalf("Test %d: Errors mismatch: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, actualErr)
|
||||
}
|
||||
@ -419,8 +419,8 @@ func TestNsLockMapStatusBlockedToRunning(t *testing.T) {
|
||||
}
|
||||
|
||||
// validating the lock origin.
|
||||
if testCase.lockOrigin != lockInfo.lockOrigin {
|
||||
t.Errorf("Test %d: Expected the lock origin info to be \"%s\", but got \"%s\"", i+1, testCase.lockOrigin, lockInfo.lockOrigin)
|
||||
if testCase.lockSource != lockInfo.lockSource {
|
||||
t.Errorf("Test %d: Expected the lock origin info to be \"%s\", but got \"%s\"", i+1, testCase.lockSource, lockInfo.lockSource)
|
||||
}
|
||||
// validating the status of the lock.
|
||||
if lockInfo.status != runningStatus {
|
||||
@ -448,7 +448,7 @@ func TestNsLockMapStatusNoneToBlocked(t *testing.T) {
|
||||
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "abcd1234",
|
||||
readLock: true,
|
||||
// expected metrics.
|
||||
@ -470,7 +470,7 @@ func TestNsLockMapStatusNoneToBlocked(t *testing.T) {
|
||||
|
||||
volume: "my-bucket",
|
||||
path: "my-object-2",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "abcd1234",
|
||||
readLock: false,
|
||||
// expected metrics.
|
||||
@ -491,7 +491,7 @@ func TestNsLockMapStatusNoneToBlocked(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "ops-Id-not-registered",
|
||||
readLock: true,
|
||||
// expected metrics.
|
||||
@ -514,7 +514,7 @@ func TestNsLockMapStatusNoneToBlocked(t *testing.T) {
|
||||
param := nsParam{testCases[0].volume, testCases[0].path}
|
||||
// Testing before the initialization done.
|
||||
// Since the data structures for
|
||||
actualErr := nsMutex.statusBlockedToRunning(param, testCases[0].lockOrigin,
|
||||
actualErr := nsMutex.statusBlockedToRunning(param, testCases[0].lockSource,
|
||||
testCases[0].opsID, testCases[0].readLock)
|
||||
|
||||
expectedErr := LockInfoVolPathMissing{testCases[0].volume, testCases[0].path}
|
||||
@ -526,7 +526,7 @@ func TestNsLockMapStatusNoneToBlocked(t *testing.T) {
|
||||
for i, testCase := range testCases {
|
||||
nsMutex.lockMapMutex.Lock()
|
||||
param := nsParam{testCase.volume, testCase.path}
|
||||
actualErr := nsMutex.statusNoneToBlocked(param, testCase.lockOrigin, testCase.opsID, testCase.readLock)
|
||||
actualErr := nsMutex.statusNoneToBlocked(param, testCase.lockSource, testCase.opsID, testCase.readLock)
|
||||
if actualErr != testCase.expectedErr {
|
||||
t.Fatalf("Test %d: Errors mismatch: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, actualErr)
|
||||
}
|
||||
@ -544,7 +544,7 @@ func TestNsLockMapDeleteLockInfoEntryForOps(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "abcd1234",
|
||||
readLock: true,
|
||||
// expected metrics.
|
||||
@ -569,12 +569,12 @@ func TestNsLockMapDeleteLockInfoEntryForOps(t *testing.T) {
|
||||
// Case - 2.
|
||||
// Lock state is set to Running and then an attempt to delete the info for non-existent opsID done.
|
||||
nsMutex.lockMapMutex.Lock()
|
||||
err := nsMutex.statusNoneToBlocked(param, testCases[0].lockOrigin, testCases[0].opsID, testCases[0].readLock)
|
||||
err := nsMutex.statusNoneToBlocked(param, testCases[0].lockSource, testCases[0].opsID, testCases[0].readLock)
|
||||
if err != nil {
|
||||
t.Fatalf("Setting lock status to Blocked failed: <ERROR> %s", err)
|
||||
}
|
||||
nsMutex.lockMapMutex.Unlock()
|
||||
err = nsMutex.statusBlockedToRunning(param, testCases[0].lockOrigin, testCases[0].opsID, testCases[0].readLock)
|
||||
err = nsMutex.statusBlockedToRunning(param, testCases[0].lockSource, testCases[0].opsID, testCases[0].readLock)
|
||||
if err != nil {
|
||||
t.Fatalf("Setting lock status to Running failed: <ERROR> %s", err)
|
||||
}
|
||||
@ -629,7 +629,7 @@ func TestNsLockMapDeleteLockInfoEntryForVolumePath(t *testing.T) {
|
||||
{
|
||||
volume: "my-bucket",
|
||||
path: "my-object",
|
||||
lockOrigin: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
lockSource: "/home/vadmeste/work/go/src/github.com/minio/minio/xl-v1-object.go:683 +0x2a",
|
||||
opsID: "abcd1234",
|
||||
readLock: true,
|
||||
// expected metrics.
|
||||
@ -655,12 +655,12 @@ func TestNsLockMapDeleteLockInfoEntryForVolumePath(t *testing.T) {
|
||||
|
||||
// Registering the entry first.
|
||||
nsMutex.lockMapMutex.Lock()
|
||||
err := nsMutex.statusNoneToBlocked(param, testCases[0].lockOrigin, testCases[0].opsID, testCases[0].readLock)
|
||||
err := nsMutex.statusNoneToBlocked(param, testCases[0].lockSource, testCases[0].opsID, testCases[0].readLock)
|
||||
if err != nil {
|
||||
t.Fatalf("Setting lock status to Blocked failed: <ERROR> %s", err)
|
||||
}
|
||||
nsMutex.lockMapMutex.Unlock()
|
||||
err = nsMutex.statusBlockedToRunning(param, testCases[0].lockOrigin, testCases[0].opsID, testCases[0].readLock)
|
||||
err = nsMutex.statusBlockedToRunning(param, testCases[0].lockSource, testCases[0].opsID, testCases[0].readLock)
|
||||
if err != nil {
|
||||
t.Fatalf("Setting lock status to Running failed: <ERROR> %s", err)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ type VolumeLockInfo struct {
|
||||
// structure to fill in status information for each operation with given operation ID.
|
||||
type OpsLockState struct {
|
||||
OperationID string `json:"opsID"` // String containing operation ID.
|
||||
LockOrigin string `json:"lockOrigin"` // Operation type (GetObject, PutObject...)
|
||||
LockSource string `json:"lockSource"` // Operation type (GetObject, PutObject...)
|
||||
LockType lockType `json:"lockType"` // Lock type (RLock, WLock)
|
||||
Status statusType `json:"status"` // Status can be Running/Ready/Blocked.
|
||||
Since time.Time `json:"statusSince"` // Time when the lock was initially held.
|
||||
@ -80,7 +80,7 @@ func getSystemLockState() (SystemLockState, error) {
|
||||
for opsID, lockInfo := range debugLock.lockInfo {
|
||||
volLockInfo.LockDetailsOnObject = append(volLockInfo.LockDetailsOnObject, OpsLockState{
|
||||
OperationID: opsID,
|
||||
LockOrigin: lockInfo.lockOrigin,
|
||||
LockSource: lockInfo.lockSource,
|
||||
LockType: lockInfo.lType,
|
||||
Status: lockInfo.status,
|
||||
Since: lockInfo.since,
|
||||
|
@ -45,7 +45,7 @@ type logger struct {
|
||||
}
|
||||
|
||||
// Get file, line, function name of the caller.
|
||||
func callerLocation() string {
|
||||
func callerSource() string {
|
||||
pc, file, line, success := runtime.Caller(2)
|
||||
if !success {
|
||||
file = "<unknown>"
|
||||
@ -59,13 +59,13 @@ func callerLocation() string {
|
||||
|
||||
// errorIf synonymous with fatalIf but doesn't exit on error != nil
|
||||
func errorIf(err error, msg string, data ...interface{}) {
|
||||
if err == nil {
|
||||
if err == nil || !isErrLogged(err) {
|
||||
return
|
||||
}
|
||||
location := callerLocation()
|
||||
source := callerSource()
|
||||
fields := logrus.Fields{
|
||||
"location": location,
|
||||
"cause": err.Error(),
|
||||
"source": source,
|
||||
"cause": err.Error(),
|
||||
}
|
||||
if e, ok := err.(*Error); ok {
|
||||
fields["stack"] = strings.Join(e.Trace(), " ")
|
||||
@ -78,13 +78,13 @@ func errorIf(err error, msg string, data ...interface{}) {
|
||||
|
||||
// fatalIf wrapper function which takes error and prints jsonic error messages.
|
||||
func fatalIf(err error, msg string, data ...interface{}) {
|
||||
if err == nil {
|
||||
if err == nil || !isErrLogged(err) {
|
||||
return
|
||||
}
|
||||
location := callerLocation()
|
||||
source := callerSource()
|
||||
fields := logrus.Fields{
|
||||
"location": location,
|
||||
"cause": err.Error(),
|
||||
"source": source,
|
||||
"cause": err.Error(),
|
||||
}
|
||||
if e, ok := err.(*Error); ok {
|
||||
fields["stack"] = strings.Join(e.Trace(), " ")
|
||||
@ -93,3 +93,20 @@ func fatalIf(err error, msg string, data ...interface{}) {
|
||||
log.WithFields(fields).Fatalf(msg, data...)
|
||||
}
|
||||
}
|
||||
|
||||
// returns false if error is not supposed to be logged.
|
||||
func isErrLogged(err error) (ok bool) {
|
||||
ok = true
|
||||
err = errorCause(err)
|
||||
switch err.(type) {
|
||||
case BucketNotFound, BucketNotEmpty, BucketExists:
|
||||
ok = false
|
||||
case ObjectNotFound, ObjectExistsAsDirectory:
|
||||
ok = false
|
||||
case BucketPolicyNotFound, InvalidUploadID:
|
||||
ok = false
|
||||
case BadDigest:
|
||||
ok = false
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Tests callerLocation.
|
||||
func TestCallerLocation(t *testing.T) {
|
||||
currentLocation := func() string { return callerLocation() }
|
||||
gotLocation := currentLocation()
|
||||
expectedLocation := "[logger_test.go:31:TestCallerLocation()]"
|
||||
if gotLocation != expectedLocation {
|
||||
t.Errorf("expected : %s, got : %s", expectedLocation, gotLocation)
|
||||
// Tests callerSource.
|
||||
func TestCallerSource(t *testing.T) {
|
||||
currentSource := func() string { return callerSource() }
|
||||
gotSource := currentSource()
|
||||
expectedSource := "[logger_test.go:31:TestCallerSource()]"
|
||||
if gotSource != expectedSource {
|
||||
t.Errorf("expected : %s, got : %s", expectedSource, gotSource)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ type nsLockMap struct {
|
||||
}
|
||||
|
||||
// Lock the namespace resource.
|
||||
func (n *nsLockMap) lock(volume, path string, lockOrigin, opsID string, readLock bool) {
|
||||
func (n *nsLockMap) lock(volume, path string, lockSource, opsID string, readLock bool) {
|
||||
var nsLk *nsLock
|
||||
n.lockMapMutex.Lock()
|
||||
|
||||
@ -128,7 +128,7 @@ func (n *nsLockMap) lock(volume, path string, lockOrigin, opsID string, readLock
|
||||
// pair of <volume, path> and <OperationID> till the lock
|
||||
// unblocks. The lock for accessing `nsMutex` is held inside
|
||||
// the function itself.
|
||||
if err := n.statusNoneToBlocked(param, lockOrigin, opsID, readLock); err != nil {
|
||||
if err := n.statusNoneToBlocked(param, lockSource, opsID, readLock); err != nil {
|
||||
errorIf(err, "Failed to set lock state to blocked")
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ func (n *nsLockMap) lock(volume, path string, lockOrigin, opsID string, readLock
|
||||
// Changing the status of the operation from blocked to
|
||||
// running. change the state of the lock to be running (from
|
||||
// blocked) for the given pair of <volume, path> and <OperationID>.
|
||||
if err := n.statusBlockedToRunning(param, lockOrigin, opsID, readLock); err != nil {
|
||||
if err := n.statusBlockedToRunning(param, lockSource, opsID, readLock); err != nil {
|
||||
errorIf(err, "Failed to set the lock state to running")
|
||||
}
|
||||
}
|
||||
@ -196,8 +196,8 @@ func (n *nsLockMap) unlock(volume, path, opsID string, readLock bool) {
|
||||
func (n *nsLockMap) Lock(volume, path, opsID string) {
|
||||
readLock := false // This is a write lock.
|
||||
|
||||
lockLocation := callerLocation() // Useful for debugging
|
||||
n.lock(volume, path, lockLocation, opsID, readLock)
|
||||
lockSource := callerSource() // Useful for debugging
|
||||
n.lock(volume, path, lockSource, opsID, readLock)
|
||||
}
|
||||
|
||||
// Unlock - unlocks any previously acquired write locks.
|
||||
@ -210,8 +210,8 @@ func (n *nsLockMap) Unlock(volume, path, opsID string) {
|
||||
func (n *nsLockMap) RLock(volume, path, opsID string) {
|
||||
readLock := true
|
||||
|
||||
lockLocation := callerLocation() // Useful for debugging
|
||||
n.lock(volume, path, lockLocation, opsID, readLock)
|
||||
lockSource := callerSource() // Useful for debugging
|
||||
n.lock(volume, path, lockSource, opsID, readLock)
|
||||
}
|
||||
|
||||
// RUnlock - unlocks any previously acquired read locks.
|
||||
@ -272,9 +272,9 @@ func (n *nsLockMap) NewNSLock(volume, path string) *lockInstance {
|
||||
|
||||
// Lock - block until write lock is taken.
|
||||
func (li *lockInstance) Lock() {
|
||||
lockLocation := callerLocation()
|
||||
lockSource := callerSource()
|
||||
readLock := false
|
||||
li.n.lock(li.volume, li.path, lockLocation, li.opsID, readLock)
|
||||
li.n.lock(li.volume, li.path, lockSource, li.opsID, readLock)
|
||||
}
|
||||
|
||||
// Unlock - block until write lock is released.
|
||||
@ -285,9 +285,9 @@ func (li *lockInstance) Unlock() {
|
||||
|
||||
// RLock - block until read lock is taken.
|
||||
func (li *lockInstance) RLock() {
|
||||
lockLocation := callerLocation()
|
||||
lockSource := callerSource()
|
||||
readLock := true
|
||||
li.n.lock(li.volume, li.path, lockLocation, li.opsID, readLock)
|
||||
li.n.lock(li.volume, li.path, lockSource, li.opsID, readLock)
|
||||
}
|
||||
|
||||
// RUnlock - block until read lock is released.
|
||||
|
@ -141,7 +141,7 @@ func TestLockStats(t *testing.T) {
|
||||
path: "my-object",
|
||||
opsID: "0",
|
||||
readLock: true,
|
||||
lockOrigin: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
lockSource: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
// expected metrics.
|
||||
expectedErr: nil,
|
||||
expectedLockStatus: "Running",
|
||||
@ -162,7 +162,7 @@ func TestLockStats(t *testing.T) {
|
||||
path: "my-object",
|
||||
opsID: "6",
|
||||
readLock: true,
|
||||
lockOrigin: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
lockSource: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
// expected metrics.
|
||||
expectedErr: nil,
|
||||
expectedLockStatus: "Running",
|
||||
@ -182,7 +182,7 @@ func TestLockStats(t *testing.T) {
|
||||
path: "my-object",
|
||||
opsID: "10",
|
||||
readLock: false,
|
||||
lockOrigin: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
lockSource: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
// expected metrics.
|
||||
expectedErr: nil,
|
||||
expectedLockStatus: "Running",
|
||||
@ -219,7 +219,7 @@ func TestLockStats(t *testing.T) {
|
||||
path: "my-object",
|
||||
opsID: "11",
|
||||
readLock: false,
|
||||
lockOrigin: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
lockSource: "[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
|
||||
// expected metrics.
|
||||
expectedErr: nil,
|
||||
expectedLockStatus: "Running",
|
||||
@ -244,7 +244,7 @@ func TestLockStats(t *testing.T) {
|
||||
readLock: false,
|
||||
// write lock is held at line 318.
|
||||
// this confirms that we are looking the right write lock.
|
||||
lockOrigin: "[lock held] in github.com/minio/minio/cmd.TestLockStats.func2[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:318]",
|
||||
lockSource: "[lock held] in github.com/minio/minio/cmd.TestLockStats.func2[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:318]",
|
||||
// expected metrics.
|
||||
expectedErr: nil,
|
||||
expectedLockStatus: "Blocked",
|
||||
@ -268,7 +268,7 @@ func TestLockStats(t *testing.T) {
|
||||
path: "my-object",
|
||||
opsID: "9",
|
||||
readLock: true,
|
||||
lockOrigin: "[lock held] in github.com/minio/minio/cmd.TestLockStats.func2[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:318]",
|
||||
lockSource: "[lock held] in github.com/minio/minio/cmd.TestLockStats.func2[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:318]",
|
||||
// expected metrics.
|
||||
expectedErr: nil,
|
||||
expectedLockStatus: "Running",
|
||||
|
Loading…
Reference in New Issue
Block a user