mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
Implement bucket expansion (#8509)
This commit is contained in:
committed by
kannappanr
parent
3a34d98db8
commit
347b29d059
@@ -59,8 +59,6 @@ import (
|
||||
"github.com/minio/minio/cmd/config"
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
"github.com/minio/minio/pkg/bpool"
|
||||
"github.com/minio/minio/pkg/dsync"
|
||||
"github.com/minio/minio/pkg/hash"
|
||||
"github.com/minio/minio/pkg/policy"
|
||||
)
|
||||
@@ -181,13 +179,13 @@ func prepareXLSets32() (ObjectLayer, []string, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
endpoints1 := mustGetNewEndpointList(fsDirs1...)
|
||||
endpoints1 := mustGetNewEndpoints(fsDirs1...)
|
||||
fsDirs2, err := getRandomDisks(16)
|
||||
if err != nil {
|
||||
removeRoots(fsDirs1)
|
||||
return nil, nil, err
|
||||
}
|
||||
endpoints2 := mustGetNewEndpointList(fsDirs2...)
|
||||
endpoints2 := mustGetNewEndpoints(fsDirs2...)
|
||||
|
||||
endpoints := append(endpoints1, endpoints2...)
|
||||
fsDirs := append(fsDirs1, fsDirs2...)
|
||||
@@ -210,7 +208,7 @@ func prepareXL(nDisks int) (ObjectLayer, []string, error) {
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
obj, _, err := initObjectLayer(mustGetNewEndpointList(fsDirs...))
|
||||
obj, _, err := initObjectLayer(mustGetZoneEndpoints(fsDirs...))
|
||||
if err != nil {
|
||||
removeRoots(fsDirs)
|
||||
return nil, nil, err
|
||||
@@ -302,7 +300,7 @@ func isSameType(obj1, obj2 interface{}) bool {
|
||||
// defer s.Stop()
|
||||
type TestServer struct {
|
||||
Root string
|
||||
Disks EndpointList
|
||||
Disks EndpointZones
|
||||
AccessKey string
|
||||
SecretKey string
|
||||
Server *httptest.Server
|
||||
@@ -331,9 +329,7 @@ func UnstartedTestServer(t TestErrHandler, instanceType string) TestServer {
|
||||
credentials := globalActiveCred
|
||||
|
||||
testServer.Obj = objLayer
|
||||
for _, disk := range disks {
|
||||
testServer.Disks = append(testServer.Disks, mustGetNewEndpointList(disk)...)
|
||||
}
|
||||
testServer.Disks = mustGetZoneEndpoints(disks...)
|
||||
testServer.AccessKey = credentials.AccessKey
|
||||
testServer.SecretKey = credentials.SecretKey
|
||||
|
||||
@@ -450,7 +446,7 @@ func resetGlobalConfig() {
|
||||
}
|
||||
|
||||
func resetGlobalEndpoints() {
|
||||
globalEndpoints = EndpointList{}
|
||||
globalEndpoints = EndpointZones{}
|
||||
}
|
||||
|
||||
func resetGlobalIsXL() {
|
||||
@@ -525,8 +521,10 @@ func newTestConfig(bucketLocation string, obj ObjectLayer) (err error) {
|
||||
// Deleting the temporary backend and stopping the server.
|
||||
func (testServer TestServer) Stop() {
|
||||
os.RemoveAll(testServer.Root)
|
||||
for _, disk := range testServer.Disks {
|
||||
os.RemoveAll(disk.Path)
|
||||
for _, ep := range testServer.Disks {
|
||||
for _, disk := range ep.Endpoints {
|
||||
os.RemoveAll(disk.Path)
|
||||
}
|
||||
}
|
||||
testServer.Server.Close()
|
||||
}
|
||||
@@ -1580,73 +1578,52 @@ func getRandomDisks(N int) ([]string, error) {
|
||||
}
|
||||
|
||||
// Initialize object layer with the supplied disks, objectLayer is nil upon any error.
|
||||
func newTestObjectLayer(endpoints EndpointList) (newObject ObjectLayer, err error) {
|
||||
func newTestObjectLayer(endpointZones EndpointZones) (newObject ObjectLayer, err error) {
|
||||
// For FS only, directly use the disk.
|
||||
isFS := len(endpoints) == 1
|
||||
if isFS {
|
||||
if endpointZones.Nodes() == 1 {
|
||||
// Initialize new FS object layer.
|
||||
return NewFSObjectLayer(endpoints[0].Path)
|
||||
return NewFSObjectLayer(endpointZones[0].Endpoints[0].Path)
|
||||
}
|
||||
|
||||
format, err := waitForFormatXL(endpoints[0].IsLocal, endpoints, 1, 16)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
storageDisks, errs := initStorageDisksWithErrors(endpoints)
|
||||
for _, err = range errs {
|
||||
if err != nil && err != errDiskNotFound {
|
||||
var formats []*formatXLV3
|
||||
for _, ep := range endpointZones {
|
||||
format, err := waitForFormatXL(ep.Endpoints[0].IsLocal, ep.Endpoints, ep.SetCount, ep.DrivesPerSet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
formats = append(formats, format)
|
||||
}
|
||||
|
||||
for i, disk := range storageDisks {
|
||||
disk.SetDiskID(format.XL.Sets[0][i])
|
||||
}
|
||||
|
||||
// Initialize list pool.
|
||||
listPool := NewTreeWalkPool(globalLookupTimeout)
|
||||
|
||||
// Initialize xl objects.
|
||||
xl := &xlObjects{
|
||||
listPool: listPool,
|
||||
storageDisks: storageDisks,
|
||||
nsMutex: newNSLock(false),
|
||||
bp: bpool.NewBytePoolCap(4, blockSizeV1, blockSizeV1*2),
|
||||
}
|
||||
|
||||
xl.getDisks = func() []StorageAPI {
|
||||
return xl.storageDisks
|
||||
}
|
||||
xl.getLockers = func() []dsync.NetLocker {
|
||||
return nil
|
||||
zones, err := newXLZones(endpointZones, formats)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
globalConfigSys = NewConfigSys()
|
||||
|
||||
globalIAMSys = NewIAMSys()
|
||||
globalIAMSys.Init(xl)
|
||||
globalIAMSys.Init(zones)
|
||||
|
||||
globalPolicySys = NewPolicySys()
|
||||
globalPolicySys.Init(nil, xl)
|
||||
globalPolicySys.Init(nil, zones)
|
||||
|
||||
globalNotificationSys = NewNotificationSys(endpoints)
|
||||
globalNotificationSys.Init(nil, xl)
|
||||
globalNotificationSys = NewNotificationSys(endpointZones)
|
||||
globalNotificationSys.Init(nil, zones)
|
||||
|
||||
return xl, nil
|
||||
return zones, nil
|
||||
}
|
||||
|
||||
// initObjectLayer - Instantiates object layer and returns it.
|
||||
func initObjectLayer(endpoints EndpointList) (ObjectLayer, []StorageAPI, error) {
|
||||
objLayer, err := newTestObjectLayer(endpoints)
|
||||
func initObjectLayer(endpointZones EndpointZones) (ObjectLayer, []StorageAPI, error) {
|
||||
objLayer, err := newTestObjectLayer(endpointZones)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var formattedDisks []StorageAPI
|
||||
// Should use the object layer tests for validating cache.
|
||||
if xl, ok := objLayer.(*xlObjects); ok {
|
||||
formattedDisks = xl.storageDisks
|
||||
if z, ok := objLayer.(*xlZones); ok {
|
||||
formattedDisks = z.zones[0].GetDisks(0)()
|
||||
}
|
||||
|
||||
// Success.
|
||||
@@ -2052,7 +2029,7 @@ func ExecObjectLayerStaleFilesTest(t *testing.T, objTest objTestStaleFilesType)
|
||||
if err != nil {
|
||||
t.Fatalf("Initialization of disks for XL setup: %s", err)
|
||||
}
|
||||
objLayer, _, err := initObjectLayer(mustGetNewEndpointList(erasureDisks...))
|
||||
objLayer, _, err := initObjectLayer(mustGetZoneEndpoints(erasureDisks...))
|
||||
if err != nil {
|
||||
t.Fatalf("Initialization of object layer failed for XL setup: %s", err)
|
||||
}
|
||||
@@ -2303,23 +2280,27 @@ func generateTLSCertKey(host string) ([]byte, []byte, error) {
|
||||
return certOut.Bytes(), keyOut.Bytes(), nil
|
||||
}
|
||||
|
||||
func mustGetNewEndpointList(args ...string) (endpoints EndpointList) {
|
||||
if len(args) == 1 {
|
||||
endpoint, err := NewEndpoint(args[0])
|
||||
logger.FatalIf(err, "unable to create new endpoint")
|
||||
endpoints = append(endpoints, endpoint)
|
||||
} else {
|
||||
var err error
|
||||
endpoints, err = NewEndpointList(args...)
|
||||
logger.FatalIf(err, "unable to create new endpoint list")
|
||||
}
|
||||
func mustGetZoneEndpoints(args ...string) EndpointZones {
|
||||
endpoints := mustGetNewEndpoints(args...)
|
||||
return []ZoneEndpoints{{
|
||||
SetCount: 1,
|
||||
DrivesPerSet: len(args),
|
||||
Endpoints: endpoints,
|
||||
}}
|
||||
}
|
||||
|
||||
func mustGetNewEndpoints(args ...string) (endpoints Endpoints) {
|
||||
endpoints, err := NewEndpoints(args...)
|
||||
logger.FatalIf(err, "unable to create new endpoint list")
|
||||
return endpoints
|
||||
}
|
||||
|
||||
func getEndpointsLocalAddr(endpoints EndpointList) string {
|
||||
for _, endpoint := range endpoints {
|
||||
if endpoint.IsLocal && endpoint.Type() == URLEndpointType {
|
||||
return endpoint.Host
|
||||
func getEndpointsLocalAddr(endpointZones EndpointZones) string {
|
||||
for _, endpoints := range endpointZones {
|
||||
for _, endpoint := range endpoints.Endpoints {
|
||||
if endpoint.IsLocal && endpoint.Type() == URLEndpointType {
|
||||
return endpoint.Host
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user