mount: fail fast when connecting to filer
fix https://github.com/chrislusf/seaweedfs/issues/1034
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
@@ -16,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/filesys"
|
"github.com/chrislusf/seaweedfs/weed/filesys"
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"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/security"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"github.com/seaweedfs/fuse"
|
"github.com/seaweedfs/fuse"
|
||||||
@@ -131,6 +133,7 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCente
|
|||||||
c.Close()
|
c.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// parse filer grpc address
|
||||||
filerGrpcAddress, err := parseFilerGrpcAddress(filer)
|
filerGrpcAddress, err := parseFilerGrpcAddress(filer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("parseFilerGrpcAddress: %v", err)
|
glog.V(0).Infof("parseFilerGrpcAddress: %v", err)
|
||||||
@@ -138,6 +141,23 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCente
|
|||||||
return true
|
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
|
mountRoot := filerMountRootPath
|
||||||
if mountRoot != "/" && strings.HasSuffix(mountRoot, "/") {
|
if mountRoot != "/" && strings.HasSuffix(mountRoot, "/") {
|
||||||
mountRoot = mountRoot[0 : len(mountRoot)-1]
|
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{
|
err = fs.Serve(c, filesys.NewSeaweedFileSystem(&filesys.Option{
|
||||||
FilerGrpcAddress: filerGrpcAddress,
|
FilerGrpcAddress: filerGrpcAddress,
|
||||||
GrpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.client"),
|
GrpcDialOption: grpcDialOption,
|
||||||
FilerMountRootPath: mountRoot,
|
FilerMountRootPath: mountRoot,
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
Replication: replication,
|
Replication: replication,
|
||||||
|
|||||||
Reference in New Issue
Block a user