Skip to content

Commit

Permalink
Merge pull request #88 from glazychev-art/log
Browse files Browse the repository at this point in the history
Update to latest sdk version
  • Loading branch information
haiodo authored Feb 9, 2021
2 parents bbccef9 + 97620a1 commit 13954a0
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/golang/protobuf v1.4.3
github.com/hashicorp/go-multierror v1.0.0
github.com/networkservicemesh/api v0.0.0-20210202152048-ec956057eb3a
github.com/networkservicemesh/sdk v0.0.0-20210208092844-64f6aa269f63
github.com/networkservicemesh/sdk v0.0.0-20210209072519-ac14b1d8f2ec
github.com/pkg/errors v0.9.1
github.com/thanhpk/randstr v1.0.4
github.com/vishvananda/netlink v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRf
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
github.com/networkservicemesh/api v0.0.0-20210202152048-ec956057eb3a h1:26MmmU399gnahAC+f6OfWsP5MpnLdJ4UjvBa6fXYvNU=
github.com/networkservicemesh/api v0.0.0-20210202152048-ec956057eb3a/go.mod h1:qvxdY1Zt4QTtiG+uH1XmjpegeHjlt5Jj4A8iK55iJPI=
github.com/networkservicemesh/sdk v0.0.0-20210208092844-64f6aa269f63 h1:fDvXYI18q3+DIN2zuljZXavL7IILWun2zafTa4llUG8=
github.com/networkservicemesh/sdk v0.0.0-20210208092844-64f6aa269f63/go.mod h1:gqv+RfDum4HBeZA0k+F96mT2m0rh9LZTUazjtsLJ0Bs=
github.com/networkservicemesh/sdk v0.0.0-20210209072519-ac14b1d8f2ec h1:DjdZBDjKzXRCE+Bzk1wu20FlA7Cu8J0aPDfkv86/6sQ=
github.com/networkservicemesh/sdk v0.0.0-20210209072519-ac14b1d8f2ec/go.mod h1:gqv+RfDum4HBeZA0k+F96mT2m0rh9LZTUazjtsLJ0Bs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nishanths/exhaustive v0.0.0-20200811152831-6cf413ae40e0/go.mod h1:wBEpHwM2OdmeNpdCvRPUlkEbBuaFmcK4Wv8Q7FuGW3c=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"git.fd.io/govpp.git/api"
interfaces "github.com/edwarnicke/govpp/binapi/interface"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
Expand All @@ -50,7 +50,7 @@ func addDel(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
}); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", swIfIndex).
WithField("prefix", ipNet).
WithField("isAdd", isAdd).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/edwarnicke/govpp/binapi/interface_types"
"github.com/edwarnicke/govpp/binapi/ip"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
Expand Down Expand Up @@ -74,7 +74,7 @@ func routeAddDel(ctx context.Context, vppConn api.Connection, swIfIndex interfac
}); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", swIfIndex).
WithField("prefix", prefix).
WithField("isAdd", isAdd).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"

Expand Down Expand Up @@ -61,7 +61,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
}); err != nil {
return err
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("Addr", ipNet.String()).
WithField("duration", time.Since(now)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"net"
"time"

"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
Expand Down Expand Up @@ -67,7 +67,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
}
for _, route := range routes {
if route.GetPrefixIPNet() == nil || to.Contains(route.GetPrefixIPNet().IP) {
logger.Log(ctx).Debugf("Skipping adding route %+v because it prefix %s is contained in %s", route, route.GetPrefixIPNet(), to)
log.FromContext(ctx).Debugf("Skipping adding route %+v because it prefix %s is contained in %s", route, route.GetPrefixIPNet(), to)
continue
}
if err := routeAdd(ctx, handle, l, netlink.SCOPE_UNIVERSE, route.GetPrefixIPNet(), to); err != nil {
Expand All @@ -91,7 +91,7 @@ func routeAdd(ctx context.Context, handle *netlink.Handle, l netlink.Link, scope
if err := handle.RouteAdd(route); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("route.Dst", route.Dst).
WithField("route.Gw", route.Gw).
Expand Down
12 changes: 6 additions & 6 deletions pkg/networkservice/mechanisms/kernel/kerneltap/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/edwarnicke/govpp/binapi/tapv2"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
Expand Down Expand Up @@ -63,7 +63,7 @@ func create(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", rsp.SwIfIndex).
WithField("HostIfName", tapCreateV2.HostIfName).
WithField("HostNamespace", tapCreateV2.HostNamespace).
Expand All @@ -78,7 +78,7 @@ func create(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
}); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", rsp.SwIfIndex).
WithField("mode", interface_types.RX_MODE_API_ADAPTIVE).
WithField("duration", time.Since(now)).
Expand All @@ -94,7 +94,7 @@ func create(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
if err != nil {
return errors.Wrapf(err, "unable to find hostIfName %s", tapCreateV2.HostIfName)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", tapCreateV2.HostIfName).
WithField("duration", time.Since(now)).
WithField("netlink", "LinkByName").Debug("completed")
Expand All @@ -106,7 +106,7 @@ func create(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
if err = handle.LinkSetAlias(l, alias); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("alias", alias).
WithField("duration", time.Since(now)).
Expand All @@ -118,7 +118,7 @@ func create(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("duration", time.Since(now)).
WithField("netlink", "LinkSetUp").Debug("completed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/edwarnicke/govpp/binapi/interface_types"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up"
Expand All @@ -52,7 +52,7 @@ func create(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", rsp.SwIfIndex).
WithField("duration", time.Since(now)).
WithField("vppapi", "AfPacketCreate").Debug("completed")
Expand All @@ -65,7 +65,7 @@ func create(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
}); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", rsp.SwIfIndex).
WithField("mode", interface_types.RX_MODE_API_ADAPTIVE).
WithField("duration", time.Since(now)).
Expand All @@ -92,7 +92,7 @@ func del(ctx context.Context, conn *networkservice.Connection, vppConn api.Conne
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", swIfIndex).
WithField("duration", time.Since(now)).
WithField("vppapi", "AfPacketDelete").Debug("completed")
Expand Down
26 changes: 13 additions & 13 deletions pkg/networkservice/mechanisms/kernel/kernelvethpair/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/networkservicemesh/sdk-vpp/pkg/tools/ethtool"

"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"
"github.com/thanhpk/randstr"
"github.com/vishvananda/netlink"
Expand All @@ -55,7 +55,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
if addErr := netlink.LinkAdd(l); addErr != nil {
return addErr
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("link.PeerName", veth.PeerName).
WithField("duration", time.Since(now)).
Expand All @@ -81,7 +81,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
if err = netlink.LinkSetNsFd(l, int(nsHandle)); err != nil {
return errors.Wrapf(err, "unable to change to netns")
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("duration", time.Since(now)).
WithField("netlink", "LinkSetNsFd").Debug("completed")
Expand All @@ -91,14 +91,14 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
name := l.Attrs().Name
l, err = handle.LinkByName(name)
if err != nil {
logger.Log(ctx).
log.FromContext(ctx).
WithField("duration", time.Since(now)).
WithField("link.Name", name).
WithField("err", err).
WithField("netlink", "LinkByName").Debug("error")
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("duration", time.Since(now)).
WithField("link.Name", name).
WithField("netlink", "LinkByName").Debug("completed")
Expand All @@ -107,15 +107,15 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
// Set the LinkName
now = time.Now()
if err = handle.LinkSetName(l, name); err != nil {
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("link.NewName", name).
WithField("duration", time.Since(now)).
WithField("err", err).
WithField("netlink", "LinkSetName").Debug("error")
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("link.NewName", name).
WithField("duration", time.Since(now)).
Expand All @@ -126,7 +126,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
if err = handle.LinkSetAlias(l, alias); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("alias", alias).
WithField("duration", time.Since(now)).
Expand All @@ -138,7 +138,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", l.Attrs().Name).
WithField("duration", time.Since(now)).
WithField("netlink", "LinkSetUp").Debug("completed")
Expand All @@ -150,7 +150,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
_ = netlink.LinkDel(l)
return err
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", veth.PeerName).
WithField("duration", time.Since(now)).
WithField("netlink", "LinkByName").Debug("completed")
Expand All @@ -162,7 +162,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
_ = netlink.LinkDel(peerLink)
return err
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", peerLink.Attrs().Name).
WithField("peerLink", fmt.Sprintf("veth-%s", alias)).
WithField("duration", time.Since(now)).
Expand All @@ -176,7 +176,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
_ = netlink.LinkDel(peerLink)
return err
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", peerLink.Attrs().Name).
WithField("duration", time.Since(now)).
WithField("netlink", "LinkSetUp").Debug("completed")
Expand All @@ -195,7 +195,7 @@ func del(ctx context.Context, conn *networkservice.Connection, isClient bool) er
if err := netlink.LinkDel(peerLink); err != nil {
return err
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("link.Name", peerLink.Attrs().Name).
WithField("duration", time.Since(now)).
WithField("netlink", "LinkDel").Debug("completed")
Expand Down
12 changes: 6 additions & 6 deletions pkg/networkservice/mechanisms/memif/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/edwarnicke/govpp/binapi/memif"
"github.com/networkservicemesh/api/pkg/api/networkservice"
memifMech "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/memif"
"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up"
Expand Down Expand Up @@ -60,7 +60,7 @@ func createMemifSocket(ctx context.Context, mechanism *memifMech.Mechanism, vppC
if _, err := memif.NewServiceClient(vppConn).MemifSocketFilenameAddDel(ctx, memifSocketAddDel); err != nil {
return 0, errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("SocketID", memifSocketAddDel.SocketID).
WithField("SocketFilename", memifSocketAddDel.SocketFilename).
WithField("IsAdd", memifSocketAddDel.IsAdd).
Expand All @@ -80,7 +80,7 @@ func deleteMemifSocket(ctx context.Context, vppConn api.Connection, isClient boo
if _, err := memif.NewServiceClient(vppConn).MemifSocketFilenameAddDel(ctx, memifSocketAddDel); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("SocketID", memifSocketAddDel.SocketID).
WithField("SocketFilename", memifSocketAddDel.SocketFilename).
WithField("IsAdd", memifSocketAddDel.IsAdd).
Expand All @@ -103,7 +103,7 @@ func createMemif(ctx context.Context, vppConn api.Connection, socketID uint32, i
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", rsp.SwIfIndex).
WithField("Role", memifCreate.Role).
WithField("SocketID", memifCreate.SocketID).
Expand All @@ -118,7 +118,7 @@ func createMemif(ctx context.Context, vppConn api.Connection, socketID uint32, i
}); err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", rsp.SwIfIndex).
WithField("mode", interface_types.RX_MODE_API_ADAPTIVE).
WithField("duration", time.Since(now)).
Expand All @@ -143,7 +143,7 @@ func deleteMemif(ctx context.Context, vppConn api.Connection, isClient bool) err
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", memifDel.SwIfIndex).
WithField("duration", time.Since(now)).
WithField("vppapi", "MemifDelete").Debug("completed")
Expand Down
4 changes: 2 additions & 2 deletions pkg/networkservice/mechanisms/vxlan/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/networkservicemesh/api/pkg/api/networkservice"
vxlanMech "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/vxlan"
"github.com/networkservicemesh/sdk/pkg/tools/logger"
"github.com/networkservicemesh/sdk/pkg/tools/log"

"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
"github.com/networkservicemesh/sdk-vpp/pkg/tools/types"
Expand Down Expand Up @@ -65,7 +65,7 @@ func addDel(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
if err != nil {
return errors.WithStack(err)
}
logger.Log(ctx).
log.FromContext(ctx).
WithField("swIfIndex", rsp.SwIfIndex).
WithField("SrcAddress", vxlanAddDelTunnel.SrcAddress).
WithField("DstAddress", vxlanAddDelTunnel.DstAddress).
Expand Down
Loading

0 comments on commit 13954a0

Please sign in to comment.