fix(bigtable): Resolve DeadlineExceeded conformance test failures (#9688)
diff --git a/bigtable/bigtable.go b/bigtable/bigtable.go
index 0b0fa55..5a1bdbb 100644
--- a/bigtable/bigtable.go
+++ b/bigtable/bigtable.go
@@ -128,6 +128,22 @@
}
}
+// Convert error to grpc status error
+func convertToGrpcStatusErr(err error) error {
+ if err != nil {
+ if errStatus, ok := status.FromError(err); ok {
+ return status.Error(errStatus.Code(), errStatus.Message())
+ }
+
+ ctxStatus := status.FromContextError(err)
+ if ctxStatus.Code() != codes.Unknown {
+ return status.Error(ctxStatus.Code(), ctxStatus.Message())
+ }
+ }
+
+ return err
+}
+
func (c *Client) fullTableName(table string) string {
return fmt.Sprintf("projects/%s/instances/%s/tables/%s", c.project, c.instance, table)
}
@@ -286,19 +302,7 @@
return err
}, retryOptions...)
- // Convert error to grpc status error
- if err != nil {
- if errStatus, ok := status.FromError(err); ok {
- return status.Error(errStatus.Code(), errStatus.Message())
- }
-
- ctxStatus := status.FromContextError(err)
- if ctxStatus.Code() != codes.Unknown {
- return status.Error(ctxStatus.Code(), ctxStatus.Message())
- }
- }
-
- return err
+ return convertToGrpcStatusErr(err)
}
// ReadRow is a convenience implementation of a single-row reader.
@@ -840,7 +844,7 @@
if err == nil {
after(res)
}
- return err
+ return convertToGrpcStatusErr(err)
}
req := &btpb.CheckAndMutateRowRequest{
@@ -873,7 +877,7 @@
if err == nil {
after(cmRes)
}
- return err
+ return convertToGrpcStatusErr(err)
}
// An ApplyOption is an optional argument to Apply.
@@ -1260,5 +1264,5 @@
}
return nil
}, retryOptions...)
- return sampledRowKeys, err
+ return sampledRowKeys, convertToGrpcStatusErr(err)
}