Skip to content

Commit

Permalink
PS: Log & return err from segfetcher (#3092)
Browse files Browse the repository at this point in the history
Instead of silently bailing out.

Fixes #3091
  • Loading branch information
lukedirtwalker authored Sep 4, 2019
1 parent 3a9e4dc commit df2dcd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions go/path_srv/internal/segreq/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//go/lib/ctrl/path_mgmt:go_default_library",
"//go/lib/ctrl/seg:go_default_library",
"//go/lib/infra:go_default_library",
"//go/lib/infra/messenger:go_default_library",
"//go/lib/infra/modules/segfetcher:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/pathdb:go_default_library",
Expand Down
8 changes: 8 additions & 0 deletions go/path_srv/internal/segreq/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/ctrl/path_mgmt"
"github.com/scionproto/scion/go/lib/infra"
"github.com/scionproto/scion/go/lib/infra/messenger"
"github.com/scionproto/scion/go/lib/infra/modules/segfetcher"
"github.com/scionproto/scion/go/lib/log"
"github.com/scionproto/scion/go/lib/pathdb"
"github.com/scionproto/scion/go/lib/revcache"
"github.com/scionproto/scion/go/path_srv/internal/handlers"
"github.com/scionproto/scion/go/proto"
)

type handler struct {
Expand Down Expand Up @@ -66,10 +68,15 @@ func (h *handler) Handle(request *infra.Request) *infra.HandlerResult {
logger.Warn("[segReqHandler] Unable to reply to client, no response writer found")
return infra.MetricsErrInternal
}
sendAck := messenger.SendAckHelper(ctx, rw)

segs, err := h.fetcher.FetchSegs(ctx,
segfetcher.Request{Src: segReq.SrcIA(), Dst: segReq.DstIA()})
if err != nil {
// TODO(lukedirtwalker): Define clearer the different errors that can
// occur and depending on them reply / return different error codes.
logger.Error("Failed to handler request", "err", err)
sendAck(proto.Ack_ErrCode_reject, err.Error())
return infra.MetricsErrInternal
}
revs, err := revcache.RelevantRevInfos(ctx, h.revCache, segs.Up, segs.Core, segs.Down)
Expand All @@ -85,6 +92,7 @@ func (h *handler) Handle(request *infra.Request) *infra.HandlerResult {
},
}
if err = rw.SendSegReply(ctx, reply); err != nil {
logger.Error("[segReqHandler] Failed to send reply", "err", err)
return infra.MetricsErrInternal
}
logger.Debug("[segReqHandler] Replied with segments", "segs", len(reply.Recs.Recs))
Expand Down

0 comments on commit df2dcd8

Please sign in to comment.