admin: Heal format in heal command (#1980)

This commit is contained in:
Anis Elleuch
2017-01-24 15:05:32 -08:00
committed by Harshavardhana
parent 973dc13cc0
commit 38c3703d08
5 changed files with 29 additions and 29 deletions
+11 -13
View File
@@ -128,17 +128,18 @@ func mainAdminHeal(ctx *cli.Context) error {
splits := splitStr(aliasedURL, "/", 3)
bucket, object := splits[1], splits[2]
// Heal format if bucket is not specified
var e error
// Heal format if bucket is not specified and quit immediately
if bucket == "" {
// TBD, Heal format - not ready yet
console.Println("Healing format is not implemented yet.")
e = client.HealFormat(isFake)
fatalIf(probe.NewError(e), "Cannot heal the specified storage format.")
return nil
}
// Heal the specified bucket
if e := client.HealBucket(bucket, isFake); e != nil {
fatalIf(probe.NewError(e), "Cannot repair bucket.")
}
e = client.HealBucket(bucket, isFake)
fatalIf(probe.NewError(e), "Cannot repair bucket.")
// Search for objects that need healing
doneCh := make(chan struct{})
@@ -148,18 +149,15 @@ func mainAdminHeal(ctx *cli.Context) error {
// Iterate over objects that need healing
for obj := range healObjectsCh {
// Return for any error
if obj.Err != nil {
fatalIf(probe.NewError(e), "Cannot list objects that need to be healed.")
}
fatalIf(probe.NewError(obj.Err), "Cannot list objects that need to be healed.")
// Check the heal status, and call heal object API only when an object can be healed
switch healInfo := *obj.HealObjectInfo; healInfo.Status {
case madmin.CanHeal:
// Heal Object
e := client.HealObject(bucket, obj.Key, isFake)
if e != nil {
errorIf(probe.NewError(e), "Cannot repair object: `"+obj.Key+"`")
}
e = client.HealObject(bucket, obj.Key, isFake)
errorIf(probe.NewError(e), "Cannot repair object: `"+obj.Key+"`")
// Print successful message
printMsg(healObjectMessage{Bucket: bucket, Object: obj})
+9 -2
View File
@@ -251,13 +251,20 @@ __Example__
```
<a name="HealFormat"></a>
### HealFormat() error
### HealFormat(isDryRun bool) error
Heal storage format on available disks. This is used when disks were replaced or were found with missing format. This is supported only for erasure-coded backend.
__Example__
``` go
err := madmClnt.HealFormat()
isDryRun := true
err := madmClnt.HealFormat(isDryRun)
if err != nil {
log.Fatalln(err)
}
isDryRun = false
err = madmClnt.HealFormat(isDryRun)
if err != nil {
log.Fatalln(err)
}
-8
View File
@@ -31,7 +31,6 @@ import (
"regexp"
"runtime"
"strings"
"time"
"github.com/minio/minio-go/pkg/s3signer"
"github.com/minio/minio-go/pkg/s3utils"
@@ -165,13 +164,6 @@ func (c *AdminClient) SetCustomTransport(customHTTPTransport http.RoundTripper)
}
}
// SetTimeout - set http client timeout.
func (c *AdminClient) SetTimeout(timeout time.Duration) {
if c.httpClient != nil {
c.httpClient.Timeout = timeout
}
}
// TraceOn - enable HTTP tracing.
func (c *AdminClient) TraceOn(outputStream io.Writer) {
// if outputStream is nil then default to os.Stdout.
+6 -3
View File
@@ -344,7 +344,7 @@ func (adm *AdminClient) HealBucket(bucket string, dryrun bool) error {
queryVal.Set("heal", "")
queryVal.Set(string(healBucket), bucket)
if dryrun {
queryVal.Set(string(healDryRun), "yes")
queryVal.Set(string(healDryRun), "")
}
hdrs := make(http.Header)
@@ -378,7 +378,7 @@ func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) error {
queryVal.Set(string(healBucket), bucket)
queryVal.Set(string(healObject), object)
if dryrun {
queryVal.Set(string(healDryRun), "yes")
queryVal.Set(string(healDryRun), "")
}
hdrs := make(http.Header)
@@ -405,9 +405,12 @@ func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) error {
}
// HealFormat - heal storage format on available disks.
func (adm *AdminClient) HealFormat() error {
func (adm *AdminClient) HealFormat(dryrun bool) error {
queryVal := url.Values{}
queryVal.Set("heal", "")
if dryrun {
queryVal.Set(string(healDryRun), "")
}
// Set x-minio-operation to format.
hdrs := make(http.Header)
+3 -3
View File
@@ -80,10 +80,10 @@
"revisionTime": "2016-08-18T00:31:20Z"
},
{
"checksumSHA1": "TVcuuhRHLezVlDqOpPMIpUZUJ+s=",
"checksumSHA1": "AK0nzlO5FfsgIp3ax76vWddmDJQ=",
"path": "github.com/minio/minio/pkg/madmin",
"revision": "fc6f804865937fccb211f4b46da0c103f2416108",
"revisionTime": "2017-01-23T17:55:34Z"
"revision": "0e693e0284def47f8a86962fa2d7fa55965e0161",
"revisionTime": "2017-01-24T16:11:05Z"
},
{
"path": "github.com/minio/minio/pkg/probe",