Skip to content

Commit

Permalink
fix: Add mutex to configurator dump (#1804)
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Fabry <[email protected]>
  • Loading branch information
ondrej-fabry authored May 12, 2021
1 parent bd7edfd commit 4121901
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions plugins/configurator/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
14 changes: 10 additions & 4 deletions plugins/configurator/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package configurator
import (
"context"
"errors"
"sync"

"go.ligato.io/cn-infra/v2/logging"

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 4121901

Please sign in to comment.