mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
fix: retain the previous UUID for newly replaced drives (#10759)
only newly replaced drives get the new `format.json`, this avoids disks reloading their in-memory reference format, ensures that drives are online without reloading the in-memory reference format. keeping reference format in-tact means UUIDs never change once they are formatted.
This commit is contained in:
@@ -25,61 +25,6 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Test get offline/online uuids.
|
||||
func TestGetUUIDs(t *testing.T) {
|
||||
fmtV2 := newFormatErasureV3(4, 16, "CRCMOD")
|
||||
formats := make([]*formatErasureV3, 64)
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 16; j++ {
|
||||
newFormat := *fmtV2
|
||||
newFormat.Erasure.This = fmtV2.Erasure.Sets[i][j]
|
||||
formats[i*16+j] = &newFormat
|
||||
}
|
||||
}
|
||||
|
||||
gotCount := len(getOnlineUUIDs(fmtV2, formats))
|
||||
if gotCount != 64 {
|
||||
t.Errorf("Expected online count '64', got '%d'", gotCount)
|
||||
}
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 16; j++ {
|
||||
if j < 4 {
|
||||
formats[i*16+j] = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gotCount = len(getOnlineUUIDs(fmtV2, formats))
|
||||
if gotCount != 48 {
|
||||
t.Errorf("Expected online count '48', got '%d'", gotCount)
|
||||
}
|
||||
|
||||
gotCount = len(getOfflineUUIDs(fmtV2, formats))
|
||||
if gotCount != 16 {
|
||||
t.Errorf("Expected offline count '16', got '%d'", gotCount)
|
||||
}
|
||||
|
||||
var errs []error
|
||||
for i := 0; i < 4*16; i++ {
|
||||
errs = append(errs, errUnformattedDisk)
|
||||
}
|
||||
|
||||
markUUIDsOffline(fmtV2, formats, errs)
|
||||
gotCount = 0
|
||||
for i := range fmtV2.Erasure.Sets {
|
||||
for j := range fmtV2.Erasure.Sets[i] {
|
||||
if fmtV2.Erasure.Sets[i][j] == offlineDiskUUID {
|
||||
gotCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
if gotCount != 16 {
|
||||
t.Errorf("Expected offline count '16', got '%d'", gotCount)
|
||||
}
|
||||
}
|
||||
|
||||
// tests fixFormatErasureV3 - fix format.json on all disks.
|
||||
func TestFixFormatV3(t *testing.T) {
|
||||
erasureDirs, err := getRandomDisks(8)
|
||||
@@ -480,6 +425,9 @@ func TestNewFormatSets(t *testing.T) {
|
||||
// Check if deployment IDs are preserved.
|
||||
for i := range newFormats {
|
||||
for j := range newFormats[i] {
|
||||
if newFormats[i][j] == nil {
|
||||
continue
|
||||
}
|
||||
if newFormats[i][j].ID != quorumFormat.ID {
|
||||
t.Fatal("Deployment id in the new format is lost")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user