Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
41f91f31
Commit
41f91f31
authored
4 years ago
by
Oliver Herms
Browse files
Options
Downloads
Patches
Plain Diff
RIS: Make logging more clear and verbose
parent
f8b1767b
Branches
ris/logging
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/ris/risserver/server.go
+13
-7
13 additions, 7 deletions
cmd/ris/risserver/server.go
with
13 additions
and
7 deletions
cmd/ris/risserver/server.go
+
13
−
7
View file @
41f91f31
...
...
@@ -11,11 +11,13 @@ import (
"github.com/bio-routing/bio-rd/routingtable/filter"
"github.com/bio-routing/bio-rd/routingtable/locRIB"
"github.com/bio-routing/bio-rd/routingtable/vrf"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
pb
"github.com/bio-routing/bio-rd/cmd/ris/api"
bnet
"github.com/bio-routing/bio-rd/net"
"github.com/bio-routing/bio-rd/net/api"
netapi
"github.com/bio-routing/bio-rd/net/api"
routeapi
"github.com/bio-routing/bio-rd/route/api"
)
...
...
@@ -53,15 +55,19 @@ func NewServer(b *server.BMPServer) *Server {
}
}
func
wrapGetRIBErr
(
err
error
,
rtr
string
,
vrfID
uint64
,
version
api
.
IP_Version
)
error
{
return
errors
.
Wrapf
(
err
,
"Unable to get RIB (%s/%s/v%d)"
,
rtr
,
vrf
.
RouteDistinguisherHumanReadable
(
vrfID
),
version
)
}
func
(
s
Server
)
getRIB
(
rtr
string
,
vrfID
uint64
,
ipVersion
netapi
.
IP_Version
)
(
*
locRIB
.
LocRIB
,
error
)
{
r
:=
s
.
bmp
.
GetRouter
(
rtr
)
if
r
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Unable to get router
%q"
,
rtr
)
return
nil
,
fmt
.
Errorf
(
"Unable to get router
"
)
}
v
:=
r
.
GetVRF
(
vrfID
)
if
v
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Unable to get VRF
%s"
,
vrf
.
RouteDistinguisherHumanReadable
(
vrfID
)
)
return
nil
,
fmt
.
Errorf
(
"Unable to get VRF
"
)
}
var
rib
*
locRIB
.
LocRIB
...
...
@@ -85,7 +91,7 @@ func (s Server) getRIB(rtr string, vrfID uint64, ipVersion netapi.IP_Version) (*
func
(
s
*
Server
)
LPM
(
ctx
context
.
Context
,
req
*
pb
.
LPMRequest
)
(
*
pb
.
LPMResponse
,
error
)
{
rib
,
err
:=
s
.
getRIB
(
req
.
Router
,
req
.
VrfId
,
req
.
Pfx
.
Address
.
Version
)
if
err
!=
nil
{
return
nil
,
err
return
nil
,
wrapGetRIBErr
(
err
,
req
.
Router
,
req
.
VrfId
,
req
.
Pfx
.
Address
.
Version
)
}
routes
:=
rib
.
LPM
(
bnet
.
NewPrefixFromProtoPrefix
(
req
.
Pfx
))
...
...
@@ -103,7 +109,7 @@ func (s *Server) LPM(ctx context.Context, req *pb.LPMRequest) (*pb.LPMResponse,
func
(
s
*
Server
)
Get
(
ctx
context
.
Context
,
req
*
pb
.
GetRequest
)
(
*
pb
.
GetResponse
,
error
)
{
rib
,
err
:=
s
.
getRIB
(
req
.
Router
,
req
.
VrfId
,
req
.
Pfx
.
Address
.
Version
)
if
err
!=
nil
{
return
nil
,
err
return
nil
,
wrapGetRIBErr
(
err
,
req
.
Router
,
req
.
VrfId
,
req
.
Pfx
.
Address
.
Version
)
}
route
:=
rib
.
Get
(
bnet
.
NewPrefixFromProtoPrefix
(
req
.
Pfx
))
...
...
@@ -124,7 +130,7 @@ func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse,
func
(
s
*
Server
)
GetLonger
(
ctx
context
.
Context
,
req
*
pb
.
GetLongerRequest
)
(
*
pb
.
GetLongerResponse
,
error
)
{
rib
,
err
:=
s
.
getRIB
(
req
.
Router
,
req
.
VrfId
,
req
.
Pfx
.
Address
.
Version
)
if
err
!=
nil
{
return
nil
,
err
return
nil
,
wrapGetRIBErr
(
err
,
req
.
Router
,
req
.
VrfId
,
req
.
Pfx
.
Address
.
Version
)
}
routes
:=
rib
.
GetLonger
(
bnet
.
NewPrefixFromProtoPrefix
(
req
.
Pfx
))
...
...
@@ -152,7 +158,7 @@ func (s *Server) ObserveRIB(req *pb.ObserveRIBRequest, stream pb.RoutingInformat
rib
,
err
:=
s
.
getRIB
(
req
.
Router
,
req
.
VrfId
,
ipVersion
)
if
err
!=
nil
{
return
err
return
wrapGetRIBErr
(
err
,
req
.
Router
,
req
.
VrfId
,
ipVersion
)
}
risObserveFIBClients
.
WithLabelValues
(
req
.
Router
,
fmt
.
Sprintf
(
"%d"
,
req
.
VrfId
),
fmt
.
Sprintf
(
"%d"
,
req
.
Afisafi
))
.
Inc
()
...
...
@@ -204,7 +210,7 @@ func (s *Server) DumpRIB(req *pb.DumpRIBRequest, stream pb.RoutingInformationSer
rib
,
err
:=
s
.
getRIB
(
req
.
Router
,
req
.
VrfId
,
ipVersion
)
if
err
!=
nil
{
return
err
return
wrapGetRIBErr
(
err
,
req
.
Router
,
req
.
VrfId
,
ipVersion
)
}
toSend
:=
&
pb
.
DumpRIBReply
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment