mirror of
https://github.com/minio/minio.git
synced 2025-04-01 10:13:42 -04:00
Assign deploymentID for first minio server in distributed setup (#7427)
- Pass local endpoints to functions fixing formatXL during startup
This commit is contained in:
parent
a4bdcba503
commit
93a9078b23
@ -488,7 +488,7 @@ func formatXLGetDeploymentID(refFormat *formatXLV3, formats []*formatXLV3) (stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// formatXLFixDeploymentID - Add deployment id if it is not present.
|
// formatXLFixDeploymentID - Add deployment id if it is not present.
|
||||||
func formatXLFixDeploymentID(ctx context.Context, storageDisks []StorageAPI, refFormat *formatXLV3) (err error) {
|
func formatXLFixDeploymentID(ctx context.Context, endpoints EndpointList, storageDisks []StorageAPI, refFormat *formatXLV3) (err error) {
|
||||||
// Acquire lock on format.json
|
// Acquire lock on format.json
|
||||||
mutex := newNSLock(globalIsDistXL)
|
mutex := newNSLock(globalIsDistXL)
|
||||||
formatLock := mutex.NewNSLock(minioMetaBucket, formatConfigFile)
|
formatLock := mutex.NewNSLock(minioMetaBucket, formatConfigFile)
|
||||||
@ -502,7 +502,7 @@ func formatXLFixDeploymentID(ctx context.Context, storageDisks []StorageAPI, ref
|
|||||||
formats, sErrs := loadFormatXLAll(storageDisks)
|
formats, sErrs := loadFormatXLAll(storageDisks)
|
||||||
for i, sErr := range sErrs {
|
for i, sErr := range sErrs {
|
||||||
if _, ok := formatCriticalErrors[sErr]; ok {
|
if _, ok := formatCriticalErrors[sErr]; ok {
|
||||||
return fmt.Errorf("Disk %s: %s", globalEndpoints[i], sErr)
|
return fmt.Errorf("Disk %s: %s", endpoints[i], sErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,11 +540,11 @@ func formatXLFixDeploymentID(ctx context.Context, storageDisks []StorageAPI, ref
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update only the valid local disks which have not been updated before.
|
// Update only the valid local disks which have not been updated before.
|
||||||
func formatXLFixLocalDeploymentID(ctx context.Context, storageDisks []StorageAPI, refFormat *formatXLV3) error {
|
func formatXLFixLocalDeploymentID(ctx context.Context, endpoints EndpointList, storageDisks []StorageAPI, refFormat *formatXLV3) error {
|
||||||
// If this server was down when the deploymentID was updated
|
// If this server was down when the deploymentID was updated
|
||||||
// then we make sure that we update the local disks with the deploymentID.
|
// then we make sure that we update the local disks with the deploymentID.
|
||||||
for index, storageDisk := range storageDisks {
|
for index, storageDisk := range storageDisks {
|
||||||
if globalEndpoints[index].IsLocal && storageDisk != nil && storageDisk.IsOnline() {
|
if endpoints[index].IsLocal && storageDisk != nil && storageDisk.IsOnline() {
|
||||||
format, err := loadFormatXL(storageDisk)
|
format, err := loadFormatXL(storageDisk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Disk can be offline etc.
|
// Disk can be offline etc.
|
||||||
|
@ -198,7 +198,14 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints EndpointLi
|
|||||||
|
|
||||||
// All disks report unformatted we should initialized everyone.
|
// All disks report unformatted we should initialized everyone.
|
||||||
if shouldInitXLDisks(sErrs) && firstDisk {
|
if shouldInitXLDisks(sErrs) && firstDisk {
|
||||||
return initFormatXL(context.Background(), storageDisks, setCount, drivesPerSet)
|
// Initialize erasure code format on disks
|
||||||
|
format, err := initFormatXL(context.Background(), storageDisks, setCount, drivesPerSet)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// Assign globalDeploymentID on first run for the
|
||||||
|
// minio server managing the first disk
|
||||||
|
globalDeploymentID = format.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return error when quorum unformatted disks - indicating we are
|
// Return error when quorum unformatted disks - indicating we are
|
||||||
@ -244,14 +251,14 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints EndpointLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format.ID == "" {
|
if format.ID == "" {
|
||||||
if err = formatXLFixDeploymentID(context.Background(), storageDisks, format); err != nil {
|
if err = formatXLFixDeploymentID(context.Background(), endpoints, storageDisks, format); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globalDeploymentID = format.ID
|
globalDeploymentID = format.ID
|
||||||
|
|
||||||
if err = formatXLFixLocalDeploymentID(context.Background(), storageDisks, format); err != nil {
|
if err = formatXLFixLocalDeploymentID(context.Background(), endpoints, storageDisks, format); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return format, nil
|
return format, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user