From dc2348daa517f21350fd0278c2fe54703bf8d3a0 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 23 Jan 2019 03:32:06 +0100 Subject: [PATCH] heal: Preserve deployment ID from reference format.json (#7126) Deployment ID is not copied into new formats after healing format. Although, this is not critical since a new deployment ID will be generated and set in the next cluster restart, it is still much better if we don't change the deployment id of a cluster for a better tracking. --- cmd/format-xl.go | 1 + cmd/format-xl_test.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/cmd/format-xl.go b/cmd/format-xl.go index dd1b70d0b..fd08fab52 100644 --- a/cmd/format-xl.go +++ b/cmd/format-xl.go @@ -896,6 +896,7 @@ func newHealFormatSets(refFormat *formatXLV3, setCount, disksPerSet int, formats if errs[i*disksPerSet+j] == errUnformattedDisk || errs[i*disksPerSet+j] == nil { newFormats[i][j] = &formatXLV3{} newFormats[i][j].Version = refFormat.Version + newFormats[i][j].ID = refFormat.ID newFormats[i][j].Format = refFormat.Format newFormats[i][j].XL.Version = refFormat.XL.Version newFormats[i][j].XL.DistributionAlgo = refFormat.XL.DistributionAlgo diff --git a/cmd/format-xl_test.go b/cmd/format-xl_test.go index d8f1aa557..4f648e38c 100644 --- a/cmd/format-xl_test.go +++ b/cmd/format-xl_test.go @@ -556,4 +556,13 @@ func TestNewFormatSets(t *testing.T) { if newFormats == nil { t.Fatal("Unexpected failure") } + + // Check if deployment IDs are preserved. + for i := range newFormats { + for j := range newFormats[i] { + if newFormats[i][j].ID != quorumFormat.ID { + t.Fatal("Deployment id in the new format is lost") + } + } + } }