mirror of
https://github.com/minio/minio.git
synced 2025-04-19 02:05:24 -04:00
Preserve same deploymentID on all zones (#8542)
This commit is contained in:
parent
347b29d059
commit
8392d2f510
@ -114,7 +114,7 @@ func initTestXLObjLayer() (ObjectLayer, []string, error) {
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
endpoints := mustGetNewEndpoints(xlDirs...)
|
endpoints := mustGetNewEndpoints(xlDirs...)
|
||||||
format, err := waitForFormatXL(true, endpoints, 1, 16)
|
format, err := waitForFormatXL(true, endpoints, 1, 16, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
removeRoots(xlDirs)
|
removeRoots(xlDirs)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
@ -287,6 +287,7 @@ func createServerEndpoints(serverAddr string, args ...string) (EndpointZones, Se
|
|||||||
if _, err := GetAllSets(args...); err != nil {
|
if _, err := GetAllSets(args...); err != nil {
|
||||||
return nil, -1, err
|
return nil, -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
setArgs, err := GetAllSets(arg)
|
setArgs, err := GetAllSets(arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -718,7 +718,7 @@ func fixFormatXLV3(storageDisks []StorageAPI, endpoints Endpoints, formats []*fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initFormatXL - save XL format configuration on all disks.
|
// initFormatXL - save XL format configuration on all disks.
|
||||||
func initFormatXL(ctx context.Context, storageDisks []StorageAPI, setCount, disksPerSet int) (format *formatXLV3, err error) {
|
func initFormatXL(ctx context.Context, storageDisks []StorageAPI, setCount, disksPerSet int, deploymentID string) (format *formatXLV3, err error) {
|
||||||
format = newFormatXLV3(setCount, disksPerSet)
|
format = newFormatXLV3(setCount, disksPerSet)
|
||||||
formats := make([]*formatXLV3, len(storageDisks))
|
formats := make([]*formatXLV3, len(storageDisks))
|
||||||
|
|
||||||
@ -726,6 +726,9 @@ func initFormatXL(ctx context.Context, storageDisks []StorageAPI, setCount, disk
|
|||||||
for j := 0; j < disksPerSet; j++ {
|
for j := 0; j < disksPerSet; j++ {
|
||||||
newFormat := *format
|
newFormat := *format
|
||||||
newFormat.XL.This = format.XL.Sets[i][j]
|
newFormat.XL.This = format.XL.Sets[i][j]
|
||||||
|
if deploymentID != "" {
|
||||||
|
newFormat.ID = deploymentID
|
||||||
|
}
|
||||||
formats[i*disksPerSet+j] = &newFormat
|
formats[i*disksPerSet+j] = &newFormat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ var errXLV3ThisEmpty = fmt.Errorf("XL format version 3 has This field empty")
|
|||||||
// connect to list of endpoints and load all XL disk formats, validate the formats are correct
|
// connect to list of endpoints and load all XL disk formats, validate the formats are correct
|
||||||
// and are in quorum, if no formats are found attempt to initialize all of them for the first
|
// and are in quorum, if no formats are found attempt to initialize all of them for the first
|
||||||
// time. additionally make sure to close all the disks used in this attempt.
|
// time. additionally make sure to close all the disks used in this attempt.
|
||||||
func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints, setCount, drivesPerSet int) (*formatXLV3, error) {
|
func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints, setCount, drivesPerSet int, deploymentID string) (*formatXLV3, error) {
|
||||||
// Initialize all storage disks
|
// Initialize all storage disks
|
||||||
storageDisks, errs := initStorageDisksWithErrors(endpoints)
|
storageDisks, errs := initStorageDisksWithErrors(endpoints)
|
||||||
defer closeStorageDisks(storageDisks)
|
defer closeStorageDisks(storageDisks)
|
||||||
@ -216,7 +216,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints,
|
|||||||
// All disks report unformatted we should initialized everyone.
|
// All disks report unformatted we should initialized everyone.
|
||||||
if shouldInitXLDisks(sErrs) && firstDisk {
|
if shouldInitXLDisks(sErrs) && firstDisk {
|
||||||
// Initialize erasure code format on disks
|
// Initialize erasure code format on disks
|
||||||
format, err := initFormatXL(context.Background(), storageDisks, setCount, drivesPerSet)
|
format, err := initFormatXL(context.Background(), storageDisks, setCount, drivesPerSet, deploymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format disks before initialization of object layer.
|
// Format disks before initialization of object layer.
|
||||||
func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, disksPerSet int) (format *formatXLV3, err error) {
|
func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, disksPerSet int, deploymentID string) (format *formatXLV3, err error) {
|
||||||
if len(endpoints) == 0 || setCount == 0 || disksPerSet == 0 {
|
if len(endpoints) == 0 || setCount == 0 || disksPerSet == 0 {
|
||||||
return nil, errInvalidArgument
|
return nil, errInvalidArgument
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, disksPerSet
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case retryCount := <-retryTimerCh:
|
case retryCount := <-retryTimerCh:
|
||||||
format, err := connectLoadInitFormats(retryCount, firstDisk, endpoints, setCount, disksPerSet)
|
format, err := connectLoadInitFormats(retryCount, firstDisk, endpoints, setCount, disksPerSet, deploymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err {
|
switch err {
|
||||||
case errNotFirstDisk:
|
case errNotFirstDisk:
|
||||||
|
@ -208,7 +208,7 @@ func initSafeModeInit(buckets []BucketInfo) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func(objLock RWLocker) {
|
||||||
objLock.Unlock()
|
objLock.Unlock()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -226,7 +226,7 @@ func initSafeModeInit(buckets []BucketInfo) (err error) {
|
|||||||
// not proceeding waiting for admin action.
|
// not proceeding waiting for admin action.
|
||||||
handleSignals()
|
handleSignals()
|
||||||
}
|
}
|
||||||
}()
|
}(objLock)
|
||||||
|
|
||||||
// Calls New() for all sub-systems.
|
// Calls New() for all sub-systems.
|
||||||
newAllSubsystems()
|
newAllSubsystems()
|
||||||
@ -437,13 +437,17 @@ func newObjectLayer(endpointZones EndpointZones) (newObject ObjectLayer, err err
|
|||||||
return NewFSObjectLayer(endpointZones[0].Endpoints[0].Path)
|
return NewFSObjectLayer(endpointZones[0].Endpoints[0].Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
var formats []*formatXLV3
|
var formats = make([]*formatXLV3, len(endpointZones))
|
||||||
for _, ep := range endpointZones {
|
var deploymentID string
|
||||||
format, err := waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints, ep.SetCount, ep.DrivesPerSet)
|
for i, ep := range endpointZones {
|
||||||
|
formats[i], err = waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints,
|
||||||
|
ep.SetCount, ep.DrivesPerSet, deploymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
formats = append(formats, format)
|
if deploymentID == "" {
|
||||||
|
deploymentID = formats[i].ID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return newXLZones(endpointZones, formats)
|
return newXLZones(endpointZones, formats)
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func prepareXLSets32() (ObjectLayer, []string, error) {
|
|||||||
|
|
||||||
endpoints := append(endpoints1, endpoints2...)
|
endpoints := append(endpoints1, endpoints2...)
|
||||||
fsDirs := append(fsDirs1, fsDirs2...)
|
fsDirs := append(fsDirs1, fsDirs2...)
|
||||||
format, err := waitForFormatXL(true, endpoints, 2, 16)
|
format, err := waitForFormatXL(true, endpoints, 2, 16, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
removeRoots(fsDirs)
|
removeRoots(fsDirs)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@ -1585,13 +1585,17 @@ func newTestObjectLayer(endpointZones EndpointZones) (newObject ObjectLayer, err
|
|||||||
return NewFSObjectLayer(endpointZones[0].Endpoints[0].Path)
|
return NewFSObjectLayer(endpointZones[0].Endpoints[0].Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
var formats []*formatXLV3
|
var formats = make([]*formatXLV3, len(endpointZones))
|
||||||
for _, ep := range endpointZones {
|
var deploymentID string
|
||||||
format, err := waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints, ep.SetCount, ep.DrivesPerSet)
|
for i, ep := range endpointZones {
|
||||||
|
formats[i], err = waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints,
|
||||||
|
ep.SetCount, ep.DrivesPerSet, deploymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
formats = append(formats, format)
|
if deploymentID == "" {
|
||||||
|
deploymentID = formats[i].ID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zones, err := newXLZones(endpointZones, formats)
|
zones, err := newXLZones(endpointZones, formats)
|
||||||
|
@ -76,18 +76,18 @@ func TestNewXLSets(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
endpoints := mustGetNewEndpoints(erasureDisks...)
|
endpoints := mustGetNewEndpoints(erasureDisks...)
|
||||||
_, err := waitForFormatXL(true, endpoints, 0, 16)
|
_, err := waitForFormatXL(true, endpoints, 0, 16, "")
|
||||||
if err != errInvalidArgument {
|
if err != errInvalidArgument {
|
||||||
t.Fatalf("Expecting error, got %s", err)
|
t.Fatalf("Expecting error, got %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = waitForFormatXL(true, nil, 1, 16)
|
_, err = waitForFormatXL(true, nil, 1, 16, "")
|
||||||
if err != errInvalidArgument {
|
if err != errInvalidArgument {
|
||||||
t.Fatalf("Expecting error, got %s", err)
|
t.Fatalf("Expecting error, got %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes all erasure disks
|
// Initializes all erasure disks
|
||||||
format, err := waitForFormatXL(true, endpoints, 1, 16)
|
format, err := waitForFormatXL(true, endpoints, 1, 16, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to format disks for erasure, %s", err)
|
t.Fatalf("Unable to format disks for erasure, %s", err)
|
||||||
}
|
}
|
||||||
|
@ -1207,7 +1207,7 @@ func (z *xlZones) HealFormat(ctx context.Context, dryRun bool) (madmin.HealResul
|
|||||||
}
|
}
|
||||||
for _, zone := range z.zones {
|
for _, zone := range z.zones {
|
||||||
result, err := zone.HealFormat(ctx, dryRun)
|
result, err := zone.HealFormat(ctx, dryRun)
|
||||||
if err != nil {
|
if err != nil && err != errNoHealRequired {
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user