Preserve same deploymentID on all zones (#8542)

master
Harshavardhana 5 years ago committed by Nitish Tiwari
parent 347b29d059
commit 8392d2f510
  1. 2
      cmd/admin-handlers_test.go
  2. 1
      cmd/endpoint-ellipses.go
  3. 5
      cmd/format-xl.go
  4. 8
      cmd/prepare-storage.go
  5. 16
      cmd/server-main.go
  6. 14
      cmd/test-utils_test.go
  7. 6
      cmd/xl-sets_test.go
  8. 2
      cmd/xl-zones.go

@ -114,7 +114,7 @@ func initTestXLObjLayer() (ObjectLayer, []string, error) {
return nil, nil, err
}
endpoints := mustGetNewEndpoints(xlDirs...)
format, err := waitForFormatXL(true, endpoints, 1, 16)
format, err := waitForFormatXL(true, endpoints, 1, 16, "")
if err != nil {
removeRoots(xlDirs)
return nil, nil, err

@ -287,6 +287,7 @@ func createServerEndpoints(serverAddr string, args ...string) (EndpointZones, Se
if _, err := GetAllSets(args...); err != nil {
return nil, -1, err
}
for _, arg := range args {
setArgs, err := GetAllSets(arg)
if err != nil {

@ -718,7 +718,7 @@ func fixFormatXLV3(storageDisks []StorageAPI, endpoints Endpoints, formats []*fo
}
// 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)
formats := make([]*formatXLV3, len(storageDisks))
@ -726,6 +726,9 @@ func initFormatXL(ctx context.Context, storageDisks []StorageAPI, setCount, disk
for j := 0; j < disksPerSet; j++ {
newFormat := *format
newFormat.XL.This = format.XL.Sets[i][j]
if deploymentID != "" {
newFormat.ID = deploymentID
}
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
// 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.
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
storageDisks, errs := initStorageDisksWithErrors(endpoints)
defer closeStorageDisks(storageDisks)
@ -216,7 +216,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints,
// All disks report unformatted we should initialized everyone.
if shouldInitXLDisks(sErrs) && firstDisk {
// 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 {
return nil, err
}
@ -286,7 +286,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints,
}
// 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 {
return nil, errInvalidArgument
}
@ -318,7 +318,7 @@ func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, disksPerSet
for {
select {
case retryCount := <-retryTimerCh:
format, err := connectLoadInitFormats(retryCount, firstDisk, endpoints, setCount, disksPerSet)
format, err := connectLoadInitFormats(retryCount, firstDisk, endpoints, setCount, disksPerSet, deploymentID)
if err != nil {
switch err {
case errNotFirstDisk:

@ -208,7 +208,7 @@ func initSafeModeInit(buckets []BucketInfo) (err error) {
return err
}
defer func() {
defer func(objLock RWLocker) {
objLock.Unlock()
if err != nil {
@ -226,7 +226,7 @@ func initSafeModeInit(buckets []BucketInfo) (err error) {
// not proceeding waiting for admin action.
handleSignals()
}
}()
}(objLock)
// Calls New() for all sub-systems.
newAllSubsystems()
@ -437,13 +437,17 @@ func newObjectLayer(endpointZones EndpointZones) (newObject ObjectLayer, err err
return NewFSObjectLayer(endpointZones[0].Endpoints[0].Path)
}
var formats []*formatXLV3
for _, ep := range endpointZones {
format, err := waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints, ep.SetCount, ep.DrivesPerSet)
var formats = make([]*formatXLV3, len(endpointZones))
var deploymentID string
for i, ep := range endpointZones {
formats[i], err = waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints,
ep.SetCount, ep.DrivesPerSet, deploymentID)
if err != nil {
return nil, err
}
formats = append(formats, format)
if deploymentID == "" {
deploymentID = formats[i].ID
}
}
return newXLZones(endpointZones, formats)
}

@ -189,7 +189,7 @@ func prepareXLSets32() (ObjectLayer, []string, error) {
endpoints := append(endpoints1, endpoints2...)
fsDirs := append(fsDirs1, fsDirs2...)
format, err := waitForFormatXL(true, endpoints, 2, 16)
format, err := waitForFormatXL(true, endpoints, 2, 16, "")
if err != nil {
removeRoots(fsDirs)
return nil, nil, err
@ -1585,13 +1585,17 @@ func newTestObjectLayer(endpointZones EndpointZones) (newObject ObjectLayer, err
return NewFSObjectLayer(endpointZones[0].Endpoints[0].Path)
}
var formats []*formatXLV3
for _, ep := range endpointZones {
format, err := waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints, ep.SetCount, ep.DrivesPerSet)
var formats = make([]*formatXLV3, len(endpointZones))
var deploymentID string
for i, ep := range endpointZones {
formats[i], err = waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints,
ep.SetCount, ep.DrivesPerSet, deploymentID)
if err != nil {
return nil, err
}
formats = append(formats, format)
if deploymentID == "" {
deploymentID = formats[i].ID
}
}
zones, err := newXLZones(endpointZones, formats)

@ -76,18 +76,18 @@ func TestNewXLSets(t *testing.T) {
}
endpoints := mustGetNewEndpoints(erasureDisks...)
_, err := waitForFormatXL(true, endpoints, 0, 16)
_, err := waitForFormatXL(true, endpoints, 0, 16, "")
if err != errInvalidArgument {
t.Fatalf("Expecting error, got %s", err)
}
_, err = waitForFormatXL(true, nil, 1, 16)
_, err = waitForFormatXL(true, nil, 1, 16, "")
if err != errInvalidArgument {
t.Fatalf("Expecting error, got %s", err)
}
// Initializes all erasure disks
format, err := waitForFormatXL(true, endpoints, 1, 16)
format, err := waitForFormatXL(true, endpoints, 1, 16, "")
if err != nil {
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 {
result, err := zone.HealFormat(ctx, dryRun)
if err != nil {
if err != nil && err != errNoHealRequired {
logger.LogIf(ctx, err)
continue
}

Loading…
Cancel
Save