diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-02-25 23:51:34 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-02-25 23:51:34 -0800 |
| commit | b1f377f8227e97a4fae0db6d38cd045eddba38f6 (patch) | |
| tree | de2799278a8e036c104a39dc486223685de92dd0 /weed/command/mount_std.go | |
| parent | 36d6595658fbd42634c3b3121a490e519bc579fb (diff) | |
| download | seaweedfs-b1f377f8227e97a4fae0db6d38cd045eddba38f6.tar.xz seaweedfs-b1f377f8227e97a4fae0db6d38cd045eddba38f6.zip | |
mount: fail fast when connecting to filer
fix https://github.com/chrislusf/seaweedfs/issues/1034
Diffstat (limited to 'weed/command/mount_std.go')
| -rw-r--r-- | weed/command/mount_std.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index ba7fb852b..1e6444ae1 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, |
