Skip to content

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.

mount: fail fast when connecting to filer

Chris Lub1f377f8227e
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go
index ba7fb852bf..1e6444ae1f 100644
--- a/weed/command/mount_std.go
+++ b/weed/command/mount_std.go
@@ -3,6 +3,7 @@
package command
import (
+ "context"
"fmt"
"os"
"os/user"
@@ -16,6 +17,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/filesys"
"github.com/chrislusf/seaweedfs/weed/glog"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/seaweedfs/fuse"
@@ -131,6 +133,7 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCente
c.Close()
})
+ // parse filer grpc address
filerGrpcAddress, err := parseFilerGrpcAddress(filer)
if err != nil {
glog.V(0).Infof("parseFilerGrpcAddress: %v", err)
@@ -138,6 +141,23 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCente
return true
}
+ // try to connect to filer, filerBucketsPath may be useful later
+ filerBucketsPath := "/buckets"
+ grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
+ err = withFilerClient(filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
+ resp, err := client.GetFilerConfiguration(context.Background(), &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
+ }
+
+ // find mount point
mountRoot := filerMountRootPath
if mountRoot != "/" && strings.HasSuffix(mountRoot, "/") {
mountRoot = mountRoot[0 : len(mountRoot)-1]
@@ -147,7 +167,7 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCente
err = fs.Serve(c, filesys.NewSeaweedFileSystem(&filesys.Option{
FilerGrpcAddress: filerGrpcAddress,
- GrpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.client"),
+ GrpcDialOption: grpcDialOption,
FilerMountRootPath: mountRoot,
Collection: collection,
Replication: replication,