aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-02-24 14:34:14 -0800
committerChris Lu <chris.lu@gmail.com>2020-02-24 14:34:14 -0800
commitd8dec2323bde1a5ab787b719a240969852004456 (patch)
tree9f8ad5b46fb713b7b951c5515ca2670a02672fc6 /weed/command
parentb06b7ca6e6257c16e006adeb8910864068b432b3 (diff)
downloadseaweedfs-d8dec2323bde1a5ab787b719a240969852004456.tar.xz
seaweedfs-d8dec2323bde1a5ab787b719a240969852004456.zip
s3: move buckets folder configuration to filer
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/filer.go3
-rw-r--r--weed/command/s3.go38
-rw-r--r--weed/command/server.go2
3 files changed, 32 insertions, 11 deletions
diff --git a/weed/command/filer.go b/weed/command/filer.go
index ea8392fac..0156fe1b9 100644
--- a/weed/command/filer.go
+++ b/weed/command/filer.go
@@ -33,6 +33,7 @@ type FilerOptions struct {
dataCenter *string
enableNotification *bool
disableHttp *bool
+ dirBucketsPath *string
// default leveldb directory, used in "weed server" mode
defaultLevelDbDirectory *string
@@ -52,6 +53,7 @@ func init() {
f.dirListingLimit = cmdFiler.Flag.Int("dirListLimit", 100000, "limit sub dir listing size")
f.dataCenter = cmdFiler.Flag.String("dataCenter", "", "prefer to write to volumes in this data center")
f.disableHttp = cmdFiler.Flag.Bool("disableHttp", false, "disable http request, only gRpc operations are allowed")
+ f.dirBucketsPath = cmdFiler.Flag.String("dir.buckets", "/buckets", "folder to store all buckets")
}
var cmdFiler = &Command{
@@ -109,6 +111,7 @@ func (fo *FilerOptions) startFiler() {
DataCenter: *fo.dataCenter,
DefaultLevelDbDir: defaultLevelDbDirectory,
DisableHttp: *fo.disableHttp,
+ DirBucketsPath: *fo.dirBucketsPath,
Port: *fo.port,
})
if nfs_err != nil {
diff --git a/weed/command/s3.go b/weed/command/s3.go
index 5fb59fcca..c1ccca820 100644
--- a/weed/command/s3.go
+++ b/weed/command/s3.go
@@ -1,10 +1,12 @@
package command
import (
+ "context"
"fmt"
"net/http"
"time"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/security"
"github.com/gorilla/mux"
@@ -19,19 +21,17 @@ var (
)
type S3Options struct {
- filer *string
- filerBucketsPath *string
- port *int
- config *string
- domainName *string
- tlsPrivateKey *string
- tlsCertificate *string
+ filer *string
+ port *int
+ config *string
+ domainName *string
+ tlsPrivateKey *string
+ tlsCertificate *string
}
func init() {
cmdS3.Run = runS3 // break init cycle
s3StandaloneOptions.filer = cmdS3.Flag.String("filer", "localhost:8888", "filer server address")
- s3StandaloneOptions.filerBucketsPath = cmdS3.Flag.String("filer.dir.buckets", "/buckets", "folder on filer to store all buckets")
s3StandaloneOptions.port = cmdS3.Flag.Int("port", 8333, "s3 server http listen port")
s3StandaloneOptions.domainName = cmdS3.Flag.String("domainName", "", "suffix of the host name, {bucket}.{domainName}")
s3StandaloneOptions.config = cmdS3.Flag.String("config", "", "path to the config file")
@@ -123,6 +123,24 @@ func (s3opt *S3Options) startS3Server() bool {
return false
}
+ filerBucketsPath := "/buckets"
+
+ grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
+ ctx := context.Background()
+
+ err = withFilerClient(ctx, filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
+ resp, err := client.GetFilerConfiguration(ctx, &filer_pb.GetFilerConfigurationRequest{})
+ if err != nil {
+ return fmt.Errorf("get filer %s configuration: %v", filerGrpcAddress, err)
+ }
+ filerBucketsPath = resp.DirBuckets
+ return nil
+ })
+ if err != nil {
+ glog.Fatal(err)
+ return false
+ }
+
router := mux.NewRouter().SkipClean(true)
_, s3ApiServer_err := s3api.NewS3ApiServer(router, &s3api.S3ApiServerOption{
@@ -130,8 +148,8 @@ func (s3opt *S3Options) startS3Server() bool {
FilerGrpcAddress: filerGrpcAddress,
Config: *s3opt.config,
DomainName: *s3opt.domainName,
- BucketsPath: *s3opt.filerBucketsPath,
- GrpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.client"),
+ BucketsPath: filerBucketsPath,
+ GrpcDialOption: grpcDialOption,
})
if s3ApiServer_err != nil {
glog.Fatalf("S3 API Server startup error: %v", s3ApiServer_err)
diff --git a/weed/command/server.go b/weed/command/server.go
index d7d768df1..aa693618c 100644
--- a/weed/command/server.go
+++ b/weed/command/server.go
@@ -82,6 +82,7 @@ func init() {
filerOptions.disableDirListing = cmdServer.Flag.Bool("filer.disableDirListing", false, "turn off directory listing")
filerOptions.maxMB = cmdServer.Flag.Int("filer.maxMB", 32, "split files larger than the limit")
filerOptions.dirListingLimit = cmdServer.Flag.Int("filer.dirListLimit", 1000, "limit sub dir listing size")
+ filerOptions.dirBucketsPath = cmdServer.Flag.String("filer.dir.buckets", "/buckets", "folder to store all buckets")
serverOptions.v.port = cmdServer.Flag.Int("volume.port", 8080, "volume server http listen port")
serverOptions.v.publicPort = cmdServer.Flag.Int("volume.port.public", 0, "volume server public port")
@@ -92,7 +93,6 @@ func init() {
serverOptions.v.fileSizeLimitMB = cmdServer.Flag.Int("volume.fileSizeLimitMB", 256, "limit file size to avoid out of memory")
serverOptions.v.publicUrl = cmdServer.Flag.String("volume.publicUrl", "", "publicly accessible address")
- s3Options.filerBucketsPath = cmdServer.Flag.String("s3.filer.dir.buckets", "/buckets", "folder on filer to store all buckets")
s3Options.port = cmdServer.Flag.Int("s3.port", 8333, "s3 server http listen port")
s3Options.domainName = cmdServer.Flag.String("s3.domainName", "", "suffix of the host name, {bucket}.{domainName}")
s3Options.tlsPrivateKey = cmdServer.Flag.String("s3.key.file", "", "path to the TLS private key file")