Heal backend configuration file (#6532)

Fixes #6461
master
Harshavardhana 6 years ago committed by Nitish Tiwari
parent 83d7ec09c1
commit aebfceeafb
  1. 27
      cmd/admin-heal-ops.go
  2. 10
      cmd/xl-v1-healing.go

@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
"path"
"runtime"
"strings"
"sync"
@ -521,6 +522,9 @@ func (h *healSequence) traverseAndHeal() {
// Start with format healing
checkErr(h.healDiskFormat)
// Start healing the config.
checkErr(h.healConfig)
// Heal buckets and objects
checkErr(h.healBuckets)
@ -531,6 +535,29 @@ func (h *healSequence) traverseAndHeal() {
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
// failure error occurred.
func (h *healSequence) healDiskFormat() error {

@ -205,10 +205,6 @@ func healBucketMetadata(xl xlObjects, bucket string, dryRun bool) (
reqInfo := &logger.ReqInfo{BucketName: bucket}
ctx := logger.SetReqInfo(context.Background(), reqInfo)
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 {
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
// should delete it.
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.
// The top level handler might not have this information.

Loading…
Cancel
Save