From 1bf5ac350fde25f693e84b8a471a0486c071fb27 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Mon, 17 Apr 2017 04:42:55 +0100 Subject: [PATCH] madmin: Update and adapt mc to new lib changes (#2131) --- cmd/admin-heal.go | 21 ++++++++--------- .../github.com/minio/minio/pkg/madmin/API.md | 23 +++++++++++++++++++ .../minio/minio/pkg/madmin/heal-commands.go | 15 ++++++++++-- .../minio/minio/pkg/madmin/lock-commands.go | 11 ++++----- vendor/vendor.json | 6 ++--- 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/cmd/admin-heal.go b/cmd/admin-heal.go index 674b1e74..42f6f992 100644 --- a/cmd/admin-heal.go +++ b/cmd/admin-heal.go @@ -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) diff --git a/vendor/github.com/minio/minio/pkg/madmin/API.md b/vendor/github.com/minio/minio/pkg/madmin/API.md index 0698c97a..dc09b997 100644 --- a/vendor/github.com/minio/minio/pkg/madmin/API.md +++ b/vendor/github.com/minio/minio/pkg/madmin/API.md @@ -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) diff --git a/vendor/github.com/minio/minio/pkg/madmin/heal-commands.go b/vendor/github.com/minio/minio/pkg/madmin/heal-commands.go index 8b69236f..4bb2cf6c 100644 --- a/vendor/github.com/minio/minio/pkg/madmin/heal-commands.go +++ b/vendor/github.com/minio/minio/pkg/madmin/heal-commands.go @@ -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. diff --git a/vendor/github.com/minio/minio/pkg/madmin/lock-commands.go b/vendor/github.com/minio/minio/pkg/madmin/lock-commands.go index 3a3b44f5..f21ff460 100644 --- a/vendor/github.com/minio/minio/pkg/madmin/lock-commands.go +++ b/vendor/github.com/minio/minio/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 diff --git a/vendor/vendor.json b/vendor/vendor.json index f8667bd7..171a2ad8 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -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",