Skip to content

Commit

Permalink
Propagate TraceNotFound error from grpc storage plugins (#2455)
Browse files Browse the repository at this point in the history
* Add test and fix to allow plugins to properly return trace not found

Signed-off-by: Joe Elliott <number101010@gmail.com>

* Changed to wrapping error in GRPC status and comparing

Signed-off-by: Joe Elliott <number101010@gmail.com>

* Compare error messages

Signed-off-by: Joe Elliott <number101010@gmail.com>

* Check s for nil

Signed-off-by: Joe Elliott <number101010@gmail.com>
  • Loading branch information
joe-elliott authored Sep 7, 2020
1 parent 9dad32f commit 5508165
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plugin/storage/grpc/shared/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func (c *grpcClient) GetTrace(ctx context.Context, traceID model.TraceID) (*mode
trace := model.Trace{}
for received, err := stream.Recv(); err != io.EOF; received, err = stream.Recv() {
if err != nil {
if e, ok := status.FromError(err); !ok {
if e.Message() == spanstore.ErrTraceNotFound.Error() {
if s, _ := status.FromError(err); s != nil {
if s.Message() == spanstore.ErrTraceNotFound.Error() {
return nil, spanstore.ErrTraceNotFound
}
}
Expand Down
5 changes: 4 additions & 1 deletion plugin/storage/grpc/shared/grpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/proto-gen/storage_v1"
Expand Down Expand Up @@ -200,9 +201,11 @@ func TestGRPCClientGetTrace_NoTrace(t *testing.T) {
}

func TestGRPCClientGetTrace_StreamErrorTraceNotFound(t *testing.T) {
s, _ := status.FromError(spanstore.ErrTraceNotFound)

withGRPCClient(func(r *grpcClientTest) {
traceClient := new(grpcMocks.SpanReaderPlugin_GetTraceClient)
traceClient.On("Recv").Return(nil, spanstore.ErrTraceNotFound)
traceClient.On("Recv").Return(nil, s.Err())
r.spanReader.On("GetTrace", mock.Anything, &storage_v1.GetTraceRequest{
TraceID: mockTraceID,
}).Return(traceClient, nil)
Expand Down

0 comments on commit 5508165

Please sign in to comment.