madmin: Update and adapt mc to new lib changes (#2131)
This commit is contained in:
committed by
Harshavardhana
parent
313d0a358f
commit
1bf5ac350f
+10
-11
@@ -101,9 +101,9 @@ type healMessage struct {
|
||||
|
||||
// String colorized service status message.
|
||||
func (u healMessage) String() string {
|
||||
allOfflineTmpl := "isn't healed since %d disks were offline"
|
||||
allHealedTmpl := "is healed on all %d disks"
|
||||
someHealedTmpl := "is healed on %d disks while %d disks were offline"
|
||||
allOfflineTmpl := "is not healed since many disks were offline"
|
||||
allHealedTmpl := "is healed on all disks"
|
||||
someHealedTmpl := "is healed on some disks while other disks were offline"
|
||||
|
||||
msg := ""
|
||||
if u.Object != nil {
|
||||
@@ -112,14 +112,13 @@ func (u healMessage) String() string {
|
||||
msg = fmt.Sprintf("Upload %s/%s/%s ", u.Bucket, u.Upload.Key, u.Upload.UploadID)
|
||||
}
|
||||
|
||||
healed, offline := u.Result.HealedCount, u.Result.OfflineCount
|
||||
switch {
|
||||
case healed == 0:
|
||||
msg += fmt.Sprintf(allOfflineTmpl, offline)
|
||||
case offline == 0:
|
||||
msg += fmt.Sprintf(allHealedTmpl, healed)
|
||||
case healed > 0 && offline > 0:
|
||||
msg += fmt.Sprintf(someHealedTmpl, healed, offline)
|
||||
switch u.Result.State {
|
||||
case madmin.HealNone:
|
||||
msg += allOfflineTmpl
|
||||
case madmin.HealPartial:
|
||||
msg += someHealedTmpl
|
||||
case madmin.HealOK:
|
||||
msg += allHealedTmpl
|
||||
}
|
||||
|
||||
return console.Colorize("Heal", msg)
|
||||
|
||||
+23
@@ -245,6 +245,18 @@ __Example__
|
||||
### HealObject(bucket, object string, isDryRun bool) (HealResult, error)
|
||||
If object is successfully healed returns nil, otherwise returns error indicating the reason for failure. If isDryRun is true, then the object is not healed, but heal object request is validated by the server. e.g, if the object exists, if object name is valid etc.
|
||||
|
||||
| Param | Type | Description |
|
||||
|---|---|---|
|
||||
|`h.State` | _HealState_ | Represents the result of heal operation. It could be one of `HealNone`, `HealPartial` or `HealOK`. |
|
||||
|
||||
|
||||
| Value | Description |
|
||||
|---|---|
|
||||
|`HealNone` | Object/Upload wasn't healed on any of the disks |
|
||||
|`HealPartial` | Object/Upload was healed on some of the disks needing heal |
|
||||
| `HealOK` | Object/Upload was healed on all the disks needing heal |
|
||||
|
||||
|
||||
__Example__
|
||||
|
||||
``` go
|
||||
@@ -327,6 +339,17 @@ __Example__
|
||||
### HealUpload(bucket, object, uploadID string, isDryRun bool) (HealResult, error)
|
||||
If upload is successfully healed returns nil, otherwise returns error indicating the reason for failure. If isDryRun is true, then the upload is not healed, but heal upload request is validated by the server. e.g, if the upload exists, if upload name is valid etc.
|
||||
|
||||
| Param | Type | Description |
|
||||
|---|---|---|
|
||||
|`h.State` | _HealState_ | Represents the result of heal operation. It could be one of `HealNone`, `HealPartial` or `HealOK`. |
|
||||
|
||||
|
||||
| Value | Description |
|
||||
|---|---|
|
||||
| `HealNone` | Object/Upload wasn't healed on any of the disks |
|
||||
| `HealPartial` | Object/Upload was healed on some of the disks needing heal |
|
||||
| `HealOK` | Object/Upload was healed on all the disks needing heal |
|
||||
|
||||
``` go
|
||||
isDryRun = false
|
||||
healResult, err := madmClnt.HealUpload("mybucket", "myobject", "myUploadID", isDryRun)
|
||||
|
||||
+13
-2
@@ -494,10 +494,21 @@ func (adm *AdminClient) HealUpload(bucket, object, uploadID string, dryrun bool)
|
||||
|
||||
// HealResult - represents result of heal-object admin API.
|
||||
type HealResult struct {
|
||||
HealedCount int // number of disks that were healed.
|
||||
OfflineCount int // number of disks that needed healing but were offline.
|
||||
State HealState `json:"state"`
|
||||
}
|
||||
|
||||
// HealState - different states of heal operation
|
||||
type HealState int
|
||||
|
||||
const (
|
||||
// HealNone - none of the disks healed
|
||||
HealNone HealState = iota
|
||||
// HealPartial - some disks were healed, others were offline
|
||||
HealPartial
|
||||
// HealOK - all disks were healed
|
||||
HealOK
|
||||
)
|
||||
|
||||
// HealObject - Heal the given object.
|
||||
func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) (HealResult, error) {
|
||||
// Construct query params.
|
||||
|
||||
+5
-6
@@ -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
|
||||
|
||||
Vendored
+3
-3
@@ -80,10 +80,10 @@
|
||||
"revisionTime": "2016-08-18T00:31:20Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "KLEdjpItmkn1LDY/2xTQHSzebnU=",
|
||||
"checksumSHA1": "v1OEKlUTmnwiQ2RxIFfDhz77Uu0=",
|
||||
"path": "github.com/minio/minio/pkg/madmin",
|
||||
"revision": "522b307ea67ed04f68fcbf98b67549532a6ac424",
|
||||
"revisionTime": "2017-04-03T11:36:28Z"
|
||||
"revision": "3032f0f505437c2f631e304cd64a7c1ed7a3479a",
|
||||
"revisionTime": "2017-04-15T18:40:01Z"
|
||||
},
|
||||
{
|
||||
"path": "github.com/minio/minio/pkg/probe",
|
||||
|
||||
Reference in New Issue
Block a user