From 2bbda71528bc9d247a6cb043bba00c5c9d786496 Mon Sep 17 00:00:00 2001 From: Uzlov Danil <36223296+d-uzlov@users.noreply.github.com> Date: Wed, 21 Jul 2021 20:03:42 +0700 Subject: [PATCH] add logs for delete operation into kerneltap server (#321) Signed-off-by: Danil Uzlov --- .../mechanisms/kernel/kerneltap/client.go | 8 +++++++- .../mechanisms/kernel/kerneltap/common.go | 10 ++++++++-- .../mechanisms/kernel/kerneltap/server.go | 7 ++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pkg/networkservice/mechanisms/kernel/kerneltap/client.go b/pkg/networkservice/mechanisms/kernel/kerneltap/client.go index 3a4bf4e0..644e49ea 100644 --- a/pkg/networkservice/mechanisms/kernel/kerneltap/client.go +++ b/pkg/networkservice/mechanisms/kernel/kerneltap/client.go @@ -23,9 +23,12 @@ import ( "git.fd.io/govpp.git/api" "github.com/golang/protobuf/ptypes/empty" + "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/cls" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" + "github.com/networkservicemesh/sdk/pkg/tools/log" + "google.golang.org/grpc" "github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata" @@ -61,6 +64,9 @@ func (k *kernelTapClient) Request(ctx context.Context, request *networkservice.N } func (k *kernelTapClient) Close(ctx context.Context, conn *networkservice.Connection, opts ...grpc.CallOption) (*empty.Empty, error) { - _ = del(ctx, conn, k.vppConn, metadata.IsClient(k)) + err := del(ctx, conn, k.vppConn, metadata.IsClient(k)) + if err != nil { + log.FromContext(ctx).Error(err) + } return next.Client(ctx).Close(ctx, conn, opts...) } diff --git a/pkg/networkservice/mechanisms/kernel/kerneltap/common.go b/pkg/networkservice/mechanisms/kernel/kerneltap/common.go index d211cc2c..ccbd86b4 100644 --- a/pkg/networkservice/mechanisms/kernel/kerneltap/common.go +++ b/pkg/networkservice/mechanisms/kernel/kerneltap/common.go @@ -26,11 +26,12 @@ import ( interfaces "github.com/edwarnicke/govpp/binapi/interface" "github.com/edwarnicke/govpp/binapi/interface_types" "github.com/edwarnicke/govpp/binapi/tapv2" + "github.com/pkg/errors" + "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel" "github.com/networkservicemesh/api/pkg/api/networkservice/payload" "github.com/networkservicemesh/sdk/pkg/tools/log" - "github.com/pkg/errors" "github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex" "github.com/networkservicemesh/sdk-vpp/pkg/tools/mechutils" @@ -139,12 +140,17 @@ func del(ctx context.Context, conn *networkservice.Connection, vppConn api.Conne if !ok { return nil } + now := time.Now() _, err := tapv2.NewServiceClient(vppConn).TapDeleteV2(ctx, &tapv2.TapDeleteV2{ SwIfIndex: swIfIndex, }) if err != nil { - return errors.WithStack(err) + return errors.Wrapf(err, "unable to delete connection with SwIfIndex %v", swIfIndex) } + log.FromContext(ctx). + WithField("SwIfIndex", swIfIndex). + WithField("duration", time.Since(now)). + WithField("vppapi", "TapDeleteV2").Debug("completed") return nil } return nil diff --git a/pkg/networkservice/mechanisms/kernel/kerneltap/server.go b/pkg/networkservice/mechanisms/kernel/kerneltap/server.go index a9b23c1e..5d4c40a0 100644 --- a/pkg/networkservice/mechanisms/kernel/kerneltap/server.go +++ b/pkg/networkservice/mechanisms/kernel/kerneltap/server.go @@ -23,8 +23,10 @@ import ( "git.fd.io/govpp.git/api" "github.com/golang/protobuf/ptypes/empty" + "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" + "github.com/networkservicemesh/sdk/pkg/tools/log" "github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata" ) @@ -53,6 +55,9 @@ func (k *kernelTapServer) Request(ctx context.Context, request *networkservice.N } func (k *kernelTapServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { - _ = del(ctx, conn, k.vppConn, metadata.IsClient(k)) + err := del(ctx, conn, k.vppConn, metadata.IsClient(k)) + if err != nil { + log.FromContext(ctx).Error(err) + } return next.Server(ctx).Close(ctx, conn) }