Heal backend configuration file (#6532)

Fixes #6461
This commit is contained in:
Harshavardhana 2018-09-29 01:17:01 -07:00 committed by Nitish Tiwari
parent 83d7ec09c1
commit aebfceeafb
2 changed files with 33 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"path"
"runtime" "runtime"
"strings" "strings"
"sync" "sync"
@ -521,6 +522,9 @@ func (h *healSequence) traverseAndHeal() {
// Start with format healing // Start with format healing
checkErr(h.healDiskFormat) checkErr(h.healDiskFormat)
// Start healing the config.
checkErr(h.healConfig)
// Heal buckets and objects // Heal buckets and objects
checkErr(h.healBuckets) checkErr(h.healBuckets)
@ -531,6 +535,29 @@ func (h *healSequence) traverseAndHeal() {
close(h.traverseAndHealDoneCh) close(h.traverseAndHealDoneCh)
} }
// healConfig - heals config.json, retrun value indicates if a failure occurred.
func (h *healSequence) healConfig() error {
// Get current object layer instance.
objectAPI := newObjectLayerFn()
if objectAPI == nil {
return errServerNotInitialized
}
configFile := path.Join(minioConfigPrefix, minioConfigFile)
configBackupFile := path.Join(minioConfigPrefix, minioConfigBackupFile)
for _, cfg := range []string{configFile, configBackupFile} {
res, err := objectAPI.HealObject(h.ctx, minioMetaBucket, cfg, h.settings.DryRun)
if err != nil {
return err
}
res.Type = madmin.HealItemBucketMetadata
if err = h.pushHealResultItem(res); err != nil {
return err
}
}
return nil
}
// healDiskFormat - heals format.json, return value indicates if a // healDiskFormat - heals format.json, return value indicates if a
// failure error occurred. // failure error occurred.
func (h *healSequence) healDiskFormat() error { func (h *healSequence) healDiskFormat() error {

View File

@ -205,10 +205,6 @@ func healBucketMetadata(xl xlObjects, bucket string, dryRun bool) (
reqInfo := &logger.ReqInfo{BucketName: bucket} reqInfo := &logger.ReqInfo{BucketName: bucket}
ctx := logger.SetReqInfo(context.Background(), reqInfo) ctx := logger.SetReqInfo(context.Background(), reqInfo)
result, healErr := xl.HealObject(ctx, minioMetaBucket, metaPath, dryRun) result, healErr := xl.HealObject(ctx, minioMetaBucket, metaPath, dryRun)
// If object is not found, no result to add.
if isErrObjectNotFound(healErr) {
return nil
}
if healErr != nil { if healErr != nil {
return healErr return healErr
} }
@ -608,6 +604,12 @@ func (xl xlObjects) healObjectDir(ctx context.Context, bucket, object string, dr
// and later the disk comes back up again, heal on the object // and later the disk comes back up again, heal on the object
// should delete it. // should delete it.
func (xl xlObjects) HealObject(ctx context.Context, bucket, object string, dryRun bool) (hr madmin.HealResultItem, err error) { func (xl xlObjects) HealObject(ctx context.Context, bucket, object string, dryRun bool) (hr madmin.HealResultItem, err error) {
defer func() {
// If object is not found, ignore the error.
if isErrObjectNotFound(err) {
err = nil
}
}()
// Create context that also contains information about the object and bucket. // Create context that also contains information about the object and bucket.
// The top level handler might not have this information. // The top level handler might not have this information.