aboutsummaryrefslogtreecommitdiff
path: root/weed/operation/assign_file_id.go
diff options
context:
space:
mode:
authorchenwanli <chenwanli@sensetime.com>2019-01-10 16:43:44 +0800
committerchenwanli <chenwanli@sensetime.com>2019-01-10 19:41:03 +0800
commit0a3e83a36a067a282a3cecec06d7bb577f1822ba (patch)
tree01ff3a3bf86f1cf81a34e0bc958ba1b0f93138b9 /weed/operation/assign_file_id.go
parent2a75a36b275ea7f47a95ad2efc70be22d5ed3fe2 (diff)
downloadseaweedfs-0a3e83a36a067a282a3cecec06d7bb577f1822ba.tar.xz
seaweedfs-0a3e83a36a067a282a3cecec06d7bb577f1822ba.zip
Set timeout for master and volume non-streaming rpc
Diffstat (limited to 'weed/operation/assign_file_id.go')
-rw-r--r--weed/operation/assign_file_id.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.go
index 924b29c0e..00e1caad5 100644
--- a/weed/operation/assign_file_id.go
+++ b/weed/operation/assign_file_id.go
@@ -3,6 +3,7 @@ package operation
import (
"context"
"fmt"
+ "time"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
)
@@ -40,6 +41,9 @@ func Assign(server string, primaryRequest *VolumeAssignRequest, alternativeReque
}
lastError = withMasterServerClient(server, func(masterClient master_pb.SeaweedClient) error {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
+ defer cancel()
+
req := &master_pb.AssignRequest{
Count: primaryRequest.Count,
Replication: primaryRequest.Replication,
@@ -49,7 +53,7 @@ func Assign(server string, primaryRequest *VolumeAssignRequest, alternativeReque
Rack: primaryRequest.Rack,
DataNode: primaryRequest.DataNode,
}
- resp, grpcErr := masterClient.Assign(context.Background(), req)
+ resp, grpcErr := masterClient.Assign(ctx, req)
if grpcErr != nil {
return grpcErr
}