From 412190182ecddb186c10fdc5112202c4488b489c Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Wed, 12 May 2021 17:01:51 +0200 Subject: [PATCH] fix: Add mutex to configurator dump (#1804) Signed-off-by: Ondrej Fabry --- plugins/configurator/configurator.go | 6 ++++-- plugins/configurator/dump.go | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/configurator/configurator.go b/plugins/configurator/configurator.go index ba62ce4997..a876cc664b 100644 --- a/plugins/configurator/configurator.go +++ b/plugins/configurator/configurator.go @@ -41,6 +41,10 @@ import ( "go.ligato.io/vpp-agent/v3/proto/ligato/vpp" ) +const ( + waitDoneCheckPendingPeriod = time.Millisecond * 10 +) + // configuratorServer implements DataSyncer service. type configuratorServer struct { pb.UnimplementedConfiguratorServiceServer @@ -75,8 +79,6 @@ func (svc *configuratorServer) Get(context.Context, *pb.GetRequest) (*pb.GetResp return &pb.GetResponse{Config: config}, nil } -const waitDoneCheckPendingPeriod = time.Millisecond * 10 - // Update adds configuration data present in data request to the VPP/Linux func (svc *configuratorServer) Update(ctx context.Context, req *pb.UpdateRequest) (*pb.UpdateResponse, error) { ctx, task := trace.NewTask(ctx, "grpc.Update") diff --git a/plugins/configurator/dump.go b/plugins/configurator/dump.go index 7386616d9e..70b09e578b 100644 --- a/plugins/configurator/dump.go +++ b/plugins/configurator/dump.go @@ -17,6 +17,7 @@ package configurator import ( "context" "errors" + "sync" "go.ligato.io/cn-infra/v2/logging" @@ -48,16 +49,18 @@ import ( type dumpService struct { log logging.Logger + mux sync.Mutex + // VPP Handlers ifHandler ifvppcalls.InterfaceVppRead l2Handler l2vppcalls.L2VppAPI l3Handler l3vppcalls.L3VppAPI ipsecHandler ipsecvppcalls.IPSecVPPRead // plugins - aclHandler aclvppcalls.ACLVppRead - abfHandler abfvppcalls.ABFVppRead - natHandler natvppcalls.NatVppRead - puntHandler vppcalls.PuntVPPRead + aclHandler aclvppcalls.ACLVppRead + abfHandler abfvppcalls.ABFVppRead + natHandler natvppcalls.NatVppRead + puntHandler vppcalls.PuntVPPRead wireguardHandler wireguardvppcalls.WgVppRead // Linux handlers @@ -69,6 +72,9 @@ type dumpService struct { func (svc *dumpService) Dump(ctx context.Context, req *rpc.DumpRequest) (*rpc.DumpResponse, error) { defer trackOperation("Dump")() + svc.mux.Lock() + defer svc.mux.Unlock() + svc.log.Debugf("Received Dump request..") dump := newConfig()