SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
add bucket creation and deletion
Chris Luc7228fefa70e
diff --git a/weed/command/s3.go b/weed/command/s3.goindex 535ffbcb10..03fa80ed81 100644--- a/weed/command/s3.go+++ b/weed/command/s3.go@@ -16,16 +16,18 @@ var ()type S3Options struct {- filer *string- filerGrpcPort *int- port *int- domainName *string+ filer *string+ filerGrpcPort *int+ filerBucketsPath *string+ port *int+ domainName *string}func init() {cmdS3.Run = runS3 // break init cycles3options.filer = cmdS3.Flag.String("filer", "localhost:8888", "filer server address")s3options.filerGrpcPort = cmdS3.Flag.Int("filer.grpcPort", 0, "filer server grpc port, default to filer http port plus 10000")+ s3options.filerBucketsPath = cmdS3.Flag.String("filer.dir.buckets", "/s3buckets", "folder on filer to store all buckets")s3options.port = cmdS3.Flag.Int("port", 8333, "s3options server http listen port")s3options.domainName = cmdS3.Flag.String("domainName", "", "suffix of the host name, {bucket}.{domainName}")}@@ -52,6 +54,7 @@ func runS3(cmd *Command, args []string) bool {Filer: *s3options.filer,FilerGrpcAddress: filerGrpcAddress,DomainName: *s3options.domainName,+ BucketsPath: *s3options.filerBucketsPath,})if s3ApiServer_err != nil {glog.Fatalf("S3 API Server startup error: %v", s3ApiServer_err)diff --git a/weed/filer2/filer.go b/weed/filer2/filer.goindex a98194bc85..2ecf3976e9 100644--- a/weed/filer2/filer.go+++ b/weed/filer2/filer.go@@ -125,7 +125,7 @@ func (f *Filer) FindEntry(p FullPath) (entry *Entry, err error) {return f.store.FindEntry(p)}-func (f *Filer) DeleteEntryMetaAndData(p FullPath, shouldDeleteChunks bool) (err error) {+func (f *Filer) DeleteEntryMetaAndData(p FullPath, isRecursive bool, shouldDeleteChunks bool) (err error) {entry, err := f.FindEntry(p)if err != nil {return err@@ -136,8 +136,14 @@ func (f *Filer) DeleteEntryMetaAndData(p FullPath, shouldDeleteChunks bool) (errif err != nil {return fmt.Errorf("list folder %s: %v", p, err)}- if len(entries) > 0 {- return fmt.Errorf("folder %s is not empty", p)+ if isRecursive {+ for _, sub := range entries {+ f.DeleteEntryMetaAndData(sub.FullPath, isRecursive, shouldDeleteChunks)+ }+ } else {+ if len(entries) > 0 {+ return fmt.Errorf("folder %s is not empty", p)+ }}f.cacheDelDirectory(string(p))}@@ -158,7 +164,7 @@ func (f *Filer) ListDirectoryEntries(p FullPath, startFileName string, inclusivefunc (f *Filer) cacheDelDirectory(dirpath string) {if f.directoryCache == nil {- return+ return}f.directoryCache.Delete(dirpath)returndiff --git a/weed/pb/filer.proto b/weed/pb/filer.protoindex fe1fe4d8de..50afcd03af 100644--- a/weed/pb/filer.proto+++ b/weed/pb/filer.proto@@ -117,6 +117,7 @@ message DeleteEntryRequest {string name = 2;bool is_directory = 3;bool is_delete_data = 4;+ bool is_recursive = 5;}message DeleteEntryResponse {diff --git a/weed/pb/filer_pb/filer.pb.go b/weed/pb/filer_pb/filer.pb.goindex 0756c6c7cd..0a451a9ec7 100644--- a/weed/pb/filer_pb/filer.pb.go+++ b/weed/pb/filer_pb/filer.pb.go@@ -452,6 +452,7 @@ type DeleteEntryRequest struct {Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`IsDirectory bool `protobuf:"varint,3,opt,name=is_directory,json=isDirectory" json:"is_directory,omitempty"`IsDeleteData bool `protobuf:"varint,4,opt,name=is_delete_data,json=isDeleteData" json:"is_delete_data,omitempty"`+ IsRecursive bool `protobuf:"varint,5,opt,name=is_recursive,json=isRecursive" json:"is_recursive,omitempty"`}func (m *DeleteEntryRequest) Reset() { *m = DeleteEntryRequest{} }@@ -487,6 +488,13 @@ func (m *DeleteEntryRequest) GetIsDeleteData() bool {return false}+func (m *DeleteEntryRequest) GetIsRecursive() bool {+ if m != nil {+ return m.IsRecursive+ }+ return false+}+type DeleteEntryResponse struct {}@@ -987,67 +995,68 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{func init() { proto.RegisterFile("filer.proto", fileDescriptor0) }var fileDescriptor0 = []byte{- // 990 bytes of a gzipped FileDescriptorProto- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x6e, 0xdc, 0x44,- 0x14, 0x8e, 0xd7, 0xbb, 0x9b, 0xf5, 0xd9, 0x4d, 0x81, 0xd9, 0xb4, 0x98, 0x6d, 0x52, 0x96, 0xa1,- 0x45, 0xa9, 0x90, 0xa2, 0x28, 0x70, 0x51, 0x81, 0x90, 0xa8, 0x92, 0x52, 0x55, 0x4a, 0x55, 0xc9,- 0x21, 0x48, 0x5c, 0xad, 0x1c, 0xfb, 0x64, 0x19, 0xc5, 0x6b, 0x2f, 0x9e, 0x71, 0x50, 0xb8, 0xe5,- 0x92, 0x0b, 0x9e, 0x02, 0xf1, 0x02, 0xbc, 0x01, 0x2f, 0x86, 0xe6, 0xc7, 0xde, 0xf1, 0xda, 0xdb,- 0x9f, 0x8b, 0xde, 0xcd, 0x9c, 0x9f, 0xef, 0x7c, 0xc7, 0x3e, 0xe7, 0xb3, 0x61, 0x78, 0xc5, 0x12,- 0xcc, 0x0f, 0x97, 0x79, 0x26, 0x32, 0x32, 0x50, 0x97, 0xd9, 0xf2, 0x92, 0xbe, 0x82, 0xfb, 0x67,- 0x59, 0x76, 0x5d, 0x2c, 0x4f, 0x59, 0x8e, 0x91, 0xc8, 0xf2, 0xdb, 0x67, 0xa9, 0xc8, 0x6f, 0x03,- 0xfc, 0xb5, 0x40, 0x2e, 0xc8, 0x1e, 0x78, 0x71, 0xe9, 0xf0, 0x9d, 0xa9, 0x73, 0xe0, 0x05, 0x2b,- 0x03, 0x21, 0xd0, 0x4d, 0xc3, 0x05, 0xfa, 0x1d, 0xe5, 0x50, 0x67, 0xfa, 0x0c, 0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79, 0x1b, 0xb0,+ 0x65, 0xea, 0x6d, 0xc0, 0xb6, 0x51, 0x09, 0xb6, 0x2e, 0xfb, 0xea, 0x97, 0xfc, 0xab, 0xff, 0x03,+ 0x00, 0x00, 0xff, 0xff, 0x27, 0x89, 0x58, 0x67, 0xa1, 0x0b, 0x00, 0x00,}diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.goindex 976bf857a5..de77da7c87 100644--- a/weed/s3api/s3api_bucket_handlers.go+++ b/weed/s3api/s3api_bucket_handlers.go@@ -7,6 +7,13 @@ import ("time""context""fmt"+ "github.com/gorilla/mux"+ "os"+)++var (+ OS_UID = uint32(os.Getuid())+ OS_GID = uint32(os.Getgid()))func (s3a *S3ApiServer) ListBucketsHandler(w http.ResponseWriter, r *http.Request) {@@ -15,7 +22,7 @@ func (s3a *S3ApiServer) ListBucketsHandler(w http.ResponseWriter, r *http.Requeserr := s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {request := &filer_pb.ListEntriesRequest{- Directory: "/buckets",+ Directory: s3a.option.BucketsPath,}glog.V(4).Infof("read directory: %v", request)@@ -56,3 +63,76 @@ func (s3a *S3ApiServer) ListBucketsHandler(w http.ResponseWriter, r *http.RequeswriteSuccessResponseXML(w, encodeResponse(response))}++func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request) {++ vars := mux.Vars(r)+ bucket := vars["bucket"]++ err := s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {++ request := &filer_pb.CreateEntryRequest{+ Directory: s3a.option.BucketsPath,+ Entry: &filer_pb.Entry{+ Name: bucket,+ IsDirectory: true,+ Attributes: &filer_pb.FuseAttributes{+ Mtime: time.Now().Unix(),+ Crtime: time.Now().Unix(),+ FileMode: uint32(0777 | os.ModeDir),+ Uid: OS_UID,+ Gid: OS_GID,+ },+ },+ }++ glog.V(1).Infof("create bucket: %v", request)+ if _, err := client.CreateEntry(context.Background(), request); err != nil {+ return fmt.Errorf("mkdir %s/%s: %v", s3a.option.BucketsPath, bucket, err)+ }++ // TODO create collection++ return nil+ })++ if err != nil {+ writeErrorResponse(w, ErrInternalError, r.URL)+ return+ }++ writeSuccessResponseEmpty(w)+}++func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) {++ vars := mux.Vars(r)+ bucket := vars["bucket"]++ // TODO delete collection++ err := s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {++ request := &filer_pb.DeleteEntryRequest{+ Directory: s3a.option.BucketsPath,+ Name: bucket,+ IsDirectory: true,+ IsDeleteData: false,+ IsRecursive: true,+ }++ glog.V(1).Infof("delete bucket: %v", request)+ if _, err := client.DeleteEntry(context.Background(), request); err != nil {+ return fmt.Errorf("delete bucket %s/%s: %v", s3a.option.BucketsPath, bucket, err)+ }++ return nil+ })++ if err != nil {+ writeErrorResponse(w, ErrInternalError, r.URL)+ return+ }++ writeResponse(w, http.StatusNoContent, nil, mimeNone)+}diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.goindex 759478fe8f..229b3a7400 100644--- a/weed/s3api/s3api_handlers.go+++ b/weed/s3api/s3api_handlers.go@@ -89,3 +89,7 @@ func writeResponse(w http.ResponseWriter, statusCode int, response []byte, mTypefunc writeSuccessResponseXML(w http.ResponseWriter, response []byte) {writeResponse(w, http.StatusOK, response, mimeXML)}++func writeSuccessResponseEmpty(w http.ResponseWriter) {+ writeResponse(w, http.StatusOK, nil, mimeNone)+}diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.goindex 2c23e62efa..267dc29ac3 100644--- a/weed/s3api/s3api_server.go+++ b/weed/s3api/s3api_server.go@@ -15,6 +15,7 @@ type S3ApiServerOption struct {Filer stringFilerGrpcAddress stringDomainName string+ BucketsPath string}type S3ApiServer struct {@@ -40,65 +41,66 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) {}routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter())- /*for _, bucket := range routers {- // HeadObject- bucket.Methods("HEAD").Path("/{object:.+}").HandlerFunc(s3a.HeadObjectHandler)- // GetObject- bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.GetObjectHandler)- // CopyObject- bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/|%2F).*?").HandlerFunc(s3a.CopyObjectHandler)- // PutObject- bucket.Methods("PUT").Path("/{object:.+}").HandlerFunc(s3a.PutObjectHandler)- // DeleteObject- bucket.Methods("DELETE").Path("/{object:.+}").HandlerFunc(s3a.DeleteObjectHandler)-- // CopyObjectPart- bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/|%2F).*?").HandlerFunc(s3a.CopyObjectPartHandler).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")- // PutObjectPart- bucket.Methods("PUT").Path("/{object:.+}").HandlerFunc(s3a.PutObjectPartHandler).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")- // ListObjectPxarts- bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.ListObjectPartsHandler).Queries("uploadId", "{uploadId:.*}")- // CompleteMultipartUpload- bucket.Methods("POST").Path("/{object:.+}").HandlerFunc(s3a.CompleteMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}")- // NewMultipartUpload- bucket.Methods("POST").Path("/{object:.+}").HandlerFunc(s3a.NewMultipartUploadHandler).Queries("uploads", "")- // AbortMultipartUpload- bucket.Methods("DELETE").Path("/{object:.+}").HandlerFunc(s3a.AbortMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}")-- // ListMultipartUploads- bucket.Methods("GET").HandlerFunc(s3a.ListMultipartUploadsHandler).Queries("uploads", "")- // ListObjectsV2- bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV2Handler).Queries("list-type", "2")- // ListObjectsV1 (Legacy)- bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV1Handler)// PutBucketbucket.Methods("PUT").HandlerFunc(s3a.PutBucketHandler)- // HeadBucket- bucket.Methods("HEAD").HandlerFunc(s3a.HeadBucketHandler)- // DeleteMultipleObjects- bucket.Methods("POST").HandlerFunc(s3a.DeleteMultipleObjectsHandler).Queries("delete", "")// DeleteBucketbucket.Methods("DELETE").HandlerFunc(s3a.DeleteBucketHandler)- // not implemented- // GetBucketLocation- bucket.Methods("GET").HandlerFunc(s3a.GetBucketLocationHandler).Queries("location", "")- // GetBucketPolicy- bucket.Methods("GET").HandlerFunc(s3a.GetBucketPolicyHandler).Queries("policy", "")- // GetObjectACL- bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.GetObjectACLHandler).Queries("acl", "")- // GetBucketACL- bucket.Methods("GET").HandlerFunc(s3a.GetBucketACLHandler).Queries("acl", "")- // PutBucketPolicy- bucket.Methods("PUT").HandlerFunc(s3a.PutBucketPolicyHandler).Queries("policy", "")- // DeleteBucketPolicy- bucket.Methods("DELETE").HandlerFunc(s3a.DeleteBucketPolicyHandler).Queries("policy", "")- // PostPolicy- bucket.Methods("POST").HeadersRegexp("Content-Type", "multipart/form-data*").HandlerFunc(s3a.PostPolicyBucketHandler)+ /*+ // HeadObject+ bucket.Methods("HEAD").Path("/{object:.+}").HandlerFunc(s3a.HeadObjectHandler)+ // GetObject+ bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.GetObjectHandler)+ // CopyObject+ bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/|%2F).*?").HandlerFunc(s3a.CopyObjectHandler)+ // PutObject+ bucket.Methods("PUT").Path("/{object:.+}").HandlerFunc(s3a.PutObjectHandler)+ // DeleteObject+ bucket.Methods("DELETE").Path("/{object:.+}").HandlerFunc(s3a.DeleteObjectHandler)++ // CopyObjectPart+ bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/|%2F).*?").HandlerFunc(s3a.CopyObjectPartHandler).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")+ // PutObjectPart+ bucket.Methods("PUT").Path("/{object:.+}").HandlerFunc(s3a.PutObjectPartHandler).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")+ // ListObjectPxarts+ bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.ListObjectPartsHandler).Queries("uploadId", "{uploadId:.*}")+ // CompleteMultipartUpload+ bucket.Methods("POST").Path("/{object:.+}").HandlerFunc(s3a.CompleteMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}")+ // NewMultipartUpload+ bucket.Methods("POST").Path("/{object:.+}").HandlerFunc(s3a.NewMultipartUploadHandler).Queries("uploads", "")+ // AbortMultipartUpload+ bucket.Methods("DELETE").Path("/{object:.+}").HandlerFunc(s3a.AbortMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}")++ // ListMultipartUploads+ bucket.Methods("GET").HandlerFunc(s3a.ListMultipartUploadsHandler).Queries("uploads", "")+ // ListObjectsV2+ bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV2Handler).Queries("list-type", "2")+ // ListObjectsV1 (Legacy)+ bucket.Methods("GET").HandlerFunc(s3a.ListObjectsV1Handler)+ // HeadBucket+ bucket.Methods("HEAD").HandlerFunc(s3a.HeadBucketHandler)+ // DeleteMultipleObjects+ bucket.Methods("POST").HandlerFunc(s3a.DeleteMultipleObjectsHandler).Queries("delete", "")++ // not implemented+ // GetBucketLocation+ bucket.Methods("GET").HandlerFunc(s3a.GetBucketLocationHandler).Queries("location", "")+ // GetBucketPolicy+ bucket.Methods("GET").HandlerFunc(s3a.GetBucketPolicyHandler).Queries("policy", "")+ // GetObjectACL+ bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(s3a.GetObjectACLHandler).Queries("acl", "")+ // GetBucketACL+ bucket.Methods("GET").HandlerFunc(s3a.GetBucketACLHandler).Queries("acl", "")+ // PutBucketPolicy+ bucket.Methods("PUT").HandlerFunc(s3a.PutBucketPolicyHandler).Queries("policy", "")+ // DeleteBucketPolicy+ bucket.Methods("DELETE").HandlerFunc(s3a.DeleteBucketPolicyHandler).Queries("policy", "")+ // PostPolicy+ bucket.Methods("POST").HeadersRegexp("Content-Type", "multipart/form-data*").HandlerFunc(s3a.PostPolicyBucketHandler)+ */}- */// ListBucketsapiRouter.Methods("GET").Path("/").HandlerFunc(s3a.ListBucketsHandler)diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.goindex 1ec5439a5f..49748af239 100644--- a/weed/server/filer_grpc_server.go+++ b/weed/server/filer_grpc_server.go@@ -162,7 +162,7 @@ func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntr}func (fs *FilerServer) DeleteEntry(ctx context.Context, req *filer_pb.DeleteEntryRequest) (resp *filer_pb.DeleteEntryResponse, err error) {- err = fs.filer.DeleteEntryMetaAndData(filer2.FullPath(filepath.Join(req.Directory, req.Name)), req.IsDeleteData)+ err = fs.filer.DeleteEntryMetaAndData(filer2.FullPath(filepath.Join(req.Directory, req.Name)), req.IsRecursive, req.IsDeleteData)return &filer_pb.DeleteEntryResponse{}, err}diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.goindex ba7c17b79c..668f14ee87 100644--- a/weed/server/filer_server_handlers_write.go+++ b/weed/server/filer_server_handlers_write.go@@ -31,11 +31,16 @@ func (fs *FilerServer) queryFileInfoByPath(w http.ResponseWriter, r *http.Requesglog.V(0).Infoln("failing to find path in filer store", path, err.Error())writeJsonError(w, r, http.StatusInternalServerError, err)} else {- fileId = entry.Chunks[0].FileId- urlLocation, err = operation.LookupFileId(fs.filer.GetMaster(), fileId)- if err != nil {- glog.V(1).Infof("operation LookupFileId %s failed, err is %s", fileId, err.Error())- w.WriteHeader(http.StatusNotFound)+ if len(entry.Chunks) == 0 {+ glog.V(1).Infof("empty entry: %s", path)+ w.WriteHeader(http.StatusNoContent)+ }else{+ fileId = entry.Chunks[0].FileId+ urlLocation, err = operation.LookupFileId(fs.filer.GetMaster(), fileId)+ if err != nil {+ glog.V(1).Infof("operation LookupFileId %s failed, err is %s", fileId, err.Error())+ w.WriteHeader(http.StatusNotFound)+ }}}return@@ -101,7 +106,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {}} else {fileId, urlLocation, err = fs.monolithicUploadAnalyzer(w, r, replication, collection, dataCenter)- if err != nil {+ if err != nil || fileId == "" {return}}@@ -215,7 +220,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {// curl -X DELETE http://localhost:8888/path/tofunc (fs *FilerServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {- err := fs.filer.DeleteEntryMetaAndData(filer2.FullPath(r.URL.Path), true)+ err := fs.filer.DeleteEntryMetaAndData(filer2.FullPath(r.URL.Path), false, true)if err != nil {glog.V(4).Infoln("deleting", r.URL.Path, ":", err.Error())writeJsonError(w, r, http.StatusInternalServerError, err)