Skip to content

Commit

Permalink
sciond: Fix TRC not found locally error logic (#3043)
Browse files Browse the repository at this point in the history
The error handling for remote TRCs not found locally is brittle.
By simply checking the error message with `common.GetErrMsg`, catching
wrapped errors is not possible.

fixes #3037
  • Loading branch information
oncilla authored Aug 26, 2019
1 parent effce5a commit af02938
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/sciond/internal/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package fetcher
import (
"bytes"
"context"
"strings"
"time"

"github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -204,7 +205,7 @@ func (f *fetcherHandler) buildReplyFromDB(ctx context.Context,
switch {
case ctx.Err() != nil:
return f.buildSCIONDReply(paths, req.MaxPaths, sciond.ErrorNoPaths), nil
case ignoreTrustNotFoundLocally && common.GetErrorMsg(err) == trust.ErrNotFoundLocally:
case ignoreTrustNotFoundLocally && f.isTrustNotFoundLocally(err):
return nil, nil
case err != nil:
return f.buildSCIONDReply(paths, req.MaxPaths, sciond.ErrorInternal), err
Expand All @@ -214,6 +215,10 @@ func (f *fetcherHandler) buildReplyFromDB(ctx context.Context,
return nil, nil
}

func (f *fetcherHandler) isTrustNotFoundLocally(err error) bool {
return err != nil && strings.Contains(err.Error(), trust.ErrNotFoundLocally)
}

// buildSCIONDReply constructs a fresh SCIOND PathReply from the information
// contained in paths. Information from the topology is used to populate the
// HostInfo field.
Expand Down

0 comments on commit af02938

Please sign in to comment.