From 3032f0f505437c2f631e304cd64a7c1ed7a3479a Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Sun, 16 Apr 2017 00:10:01 +0530 Subject: [PATCH] Remove duration field from lock instrumentation (#4111) Duration for which a lock was held can be computed from the `Since` field of `OpsLockState`. It is the difference between current time and time at which the namespace lock was held. This change avoids superfluous instrumentation. --- cmd/lock-instrument_test.go | 1 - cmd/lockinfo-handlers.go | 12 +++++------- pkg/madmin/lock-commands.go | 11 +++++------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/cmd/lock-instrument_test.go b/cmd/lock-instrument_test.go index 1cdbd8691..0b4d09545 100644 --- a/cmd/lock-instrument_test.go +++ b/cmd/lock-instrument_test.go @@ -141,7 +141,6 @@ func getSystemLockState() (SystemLockState, error) { LockType: lockInfo.lType, Status: lockInfo.status, Since: lockInfo.since, - Duration: UTCNow().Sub(lockInfo.since), }) } lockState.LocksInfoPerObject = append(lockState.LocksInfoPerObject, volLockInfo) diff --git a/cmd/lockinfo-handlers.go b/cmd/lockinfo-handlers.go index ccc01b1e4..c87c957da 100644 --- a/cmd/lockinfo-handlers.go +++ b/cmd/lockinfo-handlers.go @@ -57,12 +57,11 @@ type VolumeLockInfo struct { // OpsLockState - structure to fill in state information of the lock. // structure to fill in status information for each operation with given operation ID. type OpsLockState struct { - OperationID string `json:"id"` // String containing operation ID. - LockSource string `json:"source"` // Operation type (GetObject, PutObject...) - LockType lockType `json:"type"` // Lock type (RLock, WLock) - Status statusType `json:"status"` // Status can be Running/Ready/Blocked. - Since time.Time `json:"since"` // Time when the lock was initially held. - Duration time.Duration `json:"duration"` // Duration since the lock was held. + OperationID string `json:"id"` // String containing operation ID. + LockSource string `json:"source"` // Operation type (GetObject, PutObject...) + LockType lockType `json:"type"` // Lock type (RLock, WLock) + Status statusType `json:"status"` // Status can be Running/Ready/Blocked. + Since time.Time `json:"since"` // Time when the lock was initially held. } // listLocksInfo - Fetches locks held on bucket, matching prefix held for longer than duration. @@ -105,7 +104,6 @@ func listLocksInfo(bucket, prefix string, duration time.Duration) []VolumeLockIn LockType: lockInfo.lType, Status: lockInfo.status, Since: lockInfo.since, - Duration: elapsed, }) volumeLocks = append(volumeLocks, volLockInfo) } diff --git a/pkg/madmin/lock-commands.go b/pkg/madmin/lock-commands.go index 3a3b44f56..f21ff4602 100644 --- a/pkg/madmin/lock-commands.go +++ b/pkg/madmin/lock-commands.go @@ -42,12 +42,11 @@ const ( // OpsLockState - represents lock specific details. type OpsLockState struct { - OperationID string `json:"id"` // String containing operation ID. - LockSource string `json:"source"` // Operation type (GetObject, PutObject...) - LockType lockType `json:"type"` // Lock type (RLock, WLock) - Status statusType `json:"status"` // Status can be Running/Ready/Blocked. - Since time.Time `json:"since"` // Time when the lock was initially held. - Duration time.Duration `json:"duration"` // Duration since the lock was held. + OperationID string `json:"id"` // String containing operation ID. + LockSource string `json:"source"` // Operation type (GetObject, PutObject...) + LockType lockType `json:"type"` // Lock type (RLock, WLock) + Status statusType `json:"status"` // Status can be Running/Ready/Blocked. + Since time.Time `json:"since"` // Time when the lock was initially held. } // VolumeLockInfo - represents summary and individual lock details of all