From aebfceeafb410452d1c03edfa69b7bc5509cc1bc Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 29 Sep 2018 01:17:01 -0700 Subject: [PATCH] Heal backend configuration file (#6532) Fixes #6461 --- cmd/admin-heal-ops.go | 27 +++++++++++++++++++++++++++ cmd/xl-v1-healing.go | 10 ++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/cmd/admin-heal-ops.go b/cmd/admin-heal-ops.go index ef04c0b28..68007c4d0 100644 --- a/cmd/admin-heal-ops.go +++ b/cmd/admin-heal-ops.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 { diff --git a/cmd/xl-v1-healing.go b/cmd/xl-v1-healing.go index fa58db62c..4e2c737af 100644 --- a/cmd/xl-v1-healing.go +++ b/cmd/xl-v1-healing.go @@ -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.