diff --git a/cmd/erasure-healing.go b/cmd/erasure-healing.go index 6006eafda..a9ede26bd 100644 --- a/cmd/erasure-healing.go +++ b/cmd/erasure-healing.go @@ -614,7 +614,10 @@ func (er *erasureObjects) healObject(ctx context.Context, bucket string, object // - Remove any remaining parts from outdated disks from before transition. if recreate || partsMetadata[i].IsRemote() { rmDataDir := partsMetadata[i].DataDir - disk.DeleteVol(ctx, pathJoin(bucket, encodeDirObject(object), rmDataDir), true) + disk.Delete(ctx, bucket, pathJoin(encodeDirObject(object), rmDataDir), DeleteOptions{ + Immediate: true, + Recursive: true, + }) } for i, v := range result.Before.Drives { diff --git a/cmd/format-erasure.go b/cmd/format-erasure.go index 5c9de2a30..74dbc6363 100644 --- a/cmd/format-erasure.go +++ b/cmd/format-erasure.go @@ -353,12 +353,6 @@ func saveFormatErasure(disk StorageAPI, format *formatErasureV3, healID string) return errDiskNotFound } - diskID := format.Erasure.This - - if err := makeFormatErasureMetaVolumes(disk); err != nil { - return err - } - // Marshal and write to disk. formatBytes, err := json.Marshal(format) if err != nil { @@ -383,7 +377,7 @@ func saveFormatErasure(disk StorageAPI, format *formatErasureV3, healID string) return err } - disk.SetDiskID(diskID) + disk.SetDiskID(format.Erasure.This) if healID != "" { ctx := context.Background() ht := initHealingTracker(disk, healID) @@ -814,21 +808,6 @@ func ecDrivesNoConfig(setDriveCount int) (int, error) { return sc.GetParityForSC(storageclass.STANDARD), nil } -// Make Erasure backend meta volumes. -func makeFormatErasureMetaVolumes(disk StorageAPI) error { - if disk == nil { - return errDiskNotFound - } - volumes := []string{ - minioMetaTmpDeletedBucket, // creates .minio.sys/tmp as well as .minio.sys/tmp/.trash - minioMetaMultipartBucket, // creates .minio.sys/multipart - dataUsageBucket, // creates .minio.sys/buckets - minioConfigBucket, // creates .minio.sys/config - } - // Attempt to create MinIO internal buckets. - return disk.MakeVolBulk(context.TODO(), volumes...) -} - // Initialize a new set of set formats which will be written to all disks. func newHealFormatSets(refFormat *formatErasureV3, setCount, setDriveCount int, formats []*formatErasureV3, errs []error) ([][]*formatErasureV3, [][]DiskInfo) { newFormats := make([][]*formatErasureV3, setCount) diff --git a/cmd/storage-rest-client.go b/cmd/storage-rest-client.go index 35d1700e9..bbbb24469 100644 --- a/cmd/storage-rest-client.go +++ b/cmd/storage-rest-client.go @@ -293,32 +293,17 @@ func (client *storageRESTClient) DiskInfo(ctx context.Context, metrics bool) (in // MakeVolBulk - create multiple volumes in a bulk operation. func (client *storageRESTClient) MakeVolBulk(ctx context.Context, volumes ...string) (err error) { - values := make(url.Values) - values.Set(storageRESTVolumes, strings.Join(volumes, ",")) - respBody, err := client.call(ctx, storageRESTMethodMakeVolBulk, values, nil, -1) - defer xhttp.DrainBody(respBody) - return err + return errInvalidArgument } // MakeVol - create a volume on a remote disk. func (client *storageRESTClient) MakeVol(ctx context.Context, volume string) (err error) { - values := make(url.Values) - values.Set(storageRESTVolume, volume) - respBody, err := client.call(ctx, storageRESTMethodMakeVol, values, nil, -1) - defer xhttp.DrainBody(respBody) - return err + return errInvalidArgument } // ListVols - List all volumes on a remote disk. func (client *storageRESTClient) ListVols(ctx context.Context) (vols []VolInfo, err error) { - respBody, err := client.call(ctx, storageRESTMethodListVols, nil, nil, -1) - if err != nil { - return - } - defer xhttp.DrainBody(respBody) - vinfos := VolsInfo(vols) - err = msgp.Decode(respBody, &vinfos) - return vinfos, err + return nil, errInvalidArgument } // StatVol - get volume info over the network. @@ -337,14 +322,7 @@ func (client *storageRESTClient) StatVol(ctx context.Context, volume string) (vo // DeleteVol - Deletes a volume over the network. func (client *storageRESTClient) DeleteVol(ctx context.Context, volume string, forceDelete bool) (err error) { - values := make(url.Values) - values.Set(storageRESTVolume, volume) - if forceDelete { - values.Set(storageRESTForceDelete, "true") - } - respBody, err := client.call(ctx, storageRESTMethodDeleteVol, values, nil, -1) - defer xhttp.DrainBody(respBody) - return err + return errInvalidArgument } // AppendFile - append to a file. diff --git a/cmd/storage-rest-common.go b/cmd/storage-rest-common.go index e7875eb2b..f6e773387 100644 --- a/cmd/storage-rest-common.go +++ b/cmd/storage-rest-common.go @@ -20,17 +20,13 @@ package cmd //go:generate msgp -file $GOFILE -unexported const ( - storageRESTVersion = "v52" // Added DiskInfo drive signature + storageRESTVersion = "v53" // Remove deprecated APIs storageRESTVersionPrefix = SlashSeparator + storageRESTVersion storageRESTPrefix = minioReservedBucketPath + "/storage" ) const ( - storageRESTMethodHealth = "/health" - storageRESTMethodMakeVol = "/makevol" - storageRESTMethodMakeVolBulk = "/makevolbulk" - storageRESTMethodDeleteVol = "/deletevol" - storageRESTMethodListVols = "/listvols" + storageRESTMethodHealth = "/health" storageRESTMethodAppendFile = "/appendfile" storageRESTMethodCreateFile = "/createfile" diff --git a/cmd/storage-rest-server.go b/cmd/storage-rest-server.go index 5b405cbdb..bbe54cf66 100644 --- a/cmd/storage-rest-server.go +++ b/cmd/storage-rest-server.go @@ -305,19 +305,6 @@ func (s *storageRESTServer) StatVolHandler(params *grid.MSS) (*VolInfo, *grid.Re return &info, nil } -// DeleteVolHandler - delete a volume. -func (s *storageRESTServer) DeleteVolHandler(w http.ResponseWriter, r *http.Request) { - if !s.IsValid(w, r) { - return - } - volume := r.Form.Get(storageRESTVolume) - forceDelete := r.Form.Get(storageRESTForceDelete) == "true" - err := s.getStorage().DeleteVol(r.Context(), volume, forceDelete) - if err != nil { - s.writeErrorResponse(w, err) - } -} - // AppendFileHandler - append data from the request to the file specified. func (s *storageRESTServer) AppendFileHandler(w http.ResponseWriter, r *http.Request) { if !s.IsValid(w, r) { @@ -1359,11 +1346,6 @@ func registerStorageRESTHandlers(router *mux.Router, endpointServerPools Endpoin subrouter := router.PathPrefix(path.Join(storageRESTPrefix, endpoint.Path)).Subrouter() subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodHealth).HandlerFunc(h(server.HealthHandler)) - subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodMakeVol).HandlerFunc(h(server.MakeVolHandler)) - subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodMakeVolBulk).HandlerFunc(h(server.MakeVolBulkHandler)) - subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodDeleteVol).HandlerFunc(h(server.DeleteVolHandler)) - subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodListVols).HandlerFunc(h(server.ListVolsHandler)) - subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodAppendFile).HandlerFunc(h(server.AppendFileHandler)) subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodWriteAll).HandlerFunc(h(server.WriteAllHandler)) diff --git a/cmd/storage-rest_test.go b/cmd/storage-rest_test.go index bce633cf0..7ff4a1c31 100644 --- a/cmd/storage-rest_test.go +++ b/cmd/storage-rest_test.go @@ -53,121 +53,8 @@ func testStorageAPIDiskInfo(t *testing.T, storage StorageAPI) { } } -func testStorageAPIMakeVol(t *testing.T, storage StorageAPI) { - testCases := []struct { - volumeName string - expectErr bool - }{ - {"foo", false}, - // volume exists error. - {"foo", true}, - } - - for i, testCase := range testCases { - err := storage.MakeVol(context.Background(), testCase.volumeName) - expectErr := (err != nil) - - if expectErr != testCase.expectErr { - t.Fatalf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr) - } - } -} - -func testStorageAPIListVols(t *testing.T, storage StorageAPI) { - testCases := []struct { - volumeNames []string - expectedResult []VolInfo - expectErr bool - }{ - {nil, []VolInfo{{Name: ".minio.sys"}}, false}, - {[]string{"foo"}, []VolInfo{{Name: ".minio.sys"}, {Name: "foo"}}, false}, - } - - for i, testCase := range testCases { - for _, volumeName := range testCase.volumeNames { - err := storage.MakeVol(context.Background(), volumeName) - if err != nil { - t.Fatalf("unexpected error %v", err) - } - } - - result, err := storage.ListVols(context.Background()) - expectErr := (err != nil) - - if expectErr != testCase.expectErr { - t.Fatalf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr) - } - - if !testCase.expectErr { - if len(result) != len(testCase.expectedResult) { - t.Fatalf("case %v: result: expected: %+v, got: %+v", i+1, testCase.expectedResult, result) - } - } - } -} - -func testStorageAPIStatVol(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - - testCases := []struct { - volumeName string - expectErr bool - }{ - {"foo", false}, - // volume not found error. - {"bar", true}, - } - - for i, testCase := range testCases { - result, err := storage.StatVol(context.Background(), testCase.volumeName) - expectErr := (err != nil) - - if expectErr != testCase.expectErr { - t.Fatalf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr) - } - - if !testCase.expectErr { - if result.Name != testCase.volumeName { - t.Fatalf("case %v: result: expected: %+v, got: %+v", i+1, testCase.volumeName, result.Name) - } - } - } -} - -func testStorageAPIDeleteVol(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - - testCases := []struct { - volumeName string - expectErr bool - }{ - {"foo", false}, - // volume not found error. - {"bar", true}, - } - - for i, testCase := range testCases { - err := storage.DeleteVol(context.Background(), testCase.volumeName, false) - expectErr := (err != nil) - - if expectErr != testCase.expectErr { - t.Fatalf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr) - } - } -} - func testStorageAPIStatInfoFile(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - err = storage.AppendFile(context.Background(), "foo", pathJoin("myobject", xlStorageFormatFile), []byte("foo")) + err := storage.AppendFile(context.Background(), "foo", pathJoin("myobject", xlStorageFormatFile), []byte("foo")) if err != nil { t.Fatalf("unexpected error %v", err) } @@ -193,11 +80,7 @@ func testStorageAPIStatInfoFile(t *testing.T, storage StorageAPI) { } func testStorageAPIListDir(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - err = storage.AppendFile(context.Background(), "foo", "path/to/myobject", []byte("foo")) + err := storage.AppendFile(context.Background(), "foo", "path/to/myobject", []byte("foo")) if err != nil { t.Fatalf("unexpected error %v", err) } @@ -230,11 +113,7 @@ func testStorageAPIListDir(t *testing.T, storage StorageAPI) { } func testStorageAPIReadAll(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - err = storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) + err := storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) if err != nil { t.Fatalf("unexpected error %v", err) } @@ -267,11 +146,7 @@ func testStorageAPIReadAll(t *testing.T, storage StorageAPI) { } func testStorageAPIReadFile(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - err = storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) + err := storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) if err != nil { t.Fatalf("unexpected error %v", err) } @@ -308,11 +183,6 @@ func testStorageAPIReadFile(t *testing.T, storage StorageAPI) { } func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - testData := []byte("foo") testCases := []struct { volumeName string @@ -324,7 +194,7 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) { {"foo", "myobject", testData, false, false}, {"foo", "myobject-0byte", []byte{}, false, false}, // volume not found error. - {"bar", "myobject", testData, true, false}, + {"foo-bar", "myobject", testData, true, false}, // Test some weird characters over the wire. {"foo", "newline\n", testData, false, true}, {"foo", "newline\t", testData, false, true}, @@ -360,12 +230,7 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) { } func testStorageAPIDeleteFile(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - - err = storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) + err := storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) if err != nil { t.Fatalf("unexpected error %v", err) } @@ -396,17 +261,7 @@ func testStorageAPIDeleteFile(t *testing.T, storage StorageAPI) { } func testStorageAPIRenameFile(t *testing.T, storage StorageAPI) { - err := storage.MakeVol(context.Background(), "foo") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - - err = storage.MakeVol(context.Background(), "bar") - if err != nil { - t.Fatalf("unexpected error %v", err) - } - - err = storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) + err := storage.AppendFile(context.Background(), "foo", "myobject", []byte("foo")) if err != nil { t.Fatalf("unexpected error %v", err) } @@ -484,6 +339,15 @@ func newStorageRESTHTTPServerClient(t testing.TB) *storageRESTClient { registerStorageRESTHandlers(tg.Mux[0], poolEps, tg.Managers[0]) registerStorageRESTHandlers(tg.Mux[1], poolEps, tg.Managers[1]) + storage := globalLocalSetDrives[0][0][0] + if err = storage.MakeVol(context.Background(), "foo"); err != nil { + t.Fatalf("unexpected error %v", err) + } + + if err = storage.MakeVol(context.Background(), "bar"); err != nil { + t.Fatalf("unexpected error %v", err) + } + restClient, err := newStorageRESTClient(endpoint, false, tg.Managers[0]) if err != nil { t.Fatal(err) @@ -506,30 +370,6 @@ func TestStorageRESTClientDiskInfo(t *testing.T) { testStorageAPIDiskInfo(t, restClient) } -func TestStorageRESTClientMakeVol(t *testing.T) { - restClient := newStorageRESTHTTPServerClient(t) - - testStorageAPIMakeVol(t, restClient) -} - -func TestStorageRESTClientListVols(t *testing.T) { - restClient := newStorageRESTHTTPServerClient(t) - - testStorageAPIListVols(t, restClient) -} - -func TestStorageRESTClientStatVol(t *testing.T) { - restClient := newStorageRESTHTTPServerClient(t) - - testStorageAPIStatVol(t, restClient) -} - -func TestStorageRESTClientDeleteVol(t *testing.T) { - restClient := newStorageRESTHTTPServerClient(t) - - testStorageAPIDeleteVol(t, restClient) -} - func TestStorageRESTClientStatInfoFile(t *testing.T) { restClient := newStorageRESTHTTPServerClient(t) diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index 56eff1d4d..056769388 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -213,6 +213,21 @@ func newLocalXLStorage(path string) (*xlStorage, error) { }, true) } +// Make Erasure backend meta volumes. +func makeFormatErasureMetaVolumes(disk StorageAPI) error { + if disk == nil { + return errDiskNotFound + } + volumes := []string{ + minioMetaTmpDeletedBucket, // creates .minio.sys/tmp as well as .minio.sys/tmp/.trash + minioMetaMultipartBucket, // creates .minio.sys/multipart + dataUsageBucket, // creates .minio.sys/buckets + minioConfigBucket, // creates .minio.sys/config + } + // Attempt to create MinIO internal buckets. + return disk.MakeVolBulk(context.TODO(), volumes...) +} + // Initialize a new storage disk. func newXLStorage(ep Endpoint, cleanUp bool) (s *xlStorage, err error) { path := ep.Path @@ -279,12 +294,12 @@ func newXLStorage(ep Endpoint, cleanUp bool) (s *xlStorage, err error) { s.formatFileInfo = formatFi s.formatFile = pathJoin(s.drivePath, minioMetaBucket, formatConfigFile) - if len(s.formatData) == 0 { - // Create all necessary bucket folders if possible. - if err = makeFormatErasureMetaVolumes(s); err != nil { - return nil, err - } - } else { + // Create all necessary bucket folders if possible. + if err = makeFormatErasureMetaVolumes(s); err != nil { + return nil, err + } + + if len(s.formatData) > 0 { format := &formatErasureV3{} json := jsoniter.ConfigCompatibleWithStandardLibrary if err = json.Unmarshal(s.formatData, &format); err != nil {