Skip to content

Commit

Permalink
Improve logging in response to #1072 (comment)
Browse files Browse the repository at this point in the history
Signed-off-by: Ed Warnicke <hagbard@gmail.com>
  • Loading branch information
edwarnicke committed Aug 30, 2021
1 parent a41c6c2 commit 78d9292
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions pkg/networkservice/common/begin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"

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

"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
)

Expand Down Expand Up @@ -57,8 +59,9 @@ func (b *beginClient) Request(ctx context.Context, request *networkservice.Netwo
<-eventFactoryClient.executor.AsyncExec(func() {
// If the eventFactory has changed, usually because the connection has been Closed and re-established
// go back to the beginning and try again.
currentConnClient, _ := b.LoadOrStore(request.GetConnection().GetId(), eventFactoryClient)
if currentConnClient != eventFactoryClient {
currentEventFactoryClient, _ := b.LoadOrStore(request.GetConnection().GetId(), eventFactoryClient)
if currentEventFactoryClient != eventFactoryClient {
log.FromContext(ctx).Debug("recalling begin.Request because currentEventFactoryClient != eventFactoryClient")
conn, err = b.Request(ctx, request)
return
}
Expand Down Expand Up @@ -97,8 +100,8 @@ func (b *beginClient) Close(ctx context.Context, conn *networkservice.Connection
}

// If this isn't the connection we started with, do nothing
currentConnClient, _ := b.LoadOrStore(conn.GetId(), eventFactoryClient)
if currentConnClient != eventFactoryClient {
currentEventFactoryClient, _ := b.LoadOrStore(conn.GetId(), eventFactoryClient)
if currentEventFactoryClient != eventFactoryClient {
return
}
// Always close with the last valid Connection we got
Expand Down
7 changes: 5 additions & 2 deletions pkg/networkservice/common/begin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/pkg/errors"
"google.golang.org/protobuf/types/known/emptypb"

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

"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
)

Expand Down Expand Up @@ -53,8 +55,9 @@ func (b *beginServer) Request(ctx context.Context, request *networkservice.Netwo
),
)
<-eventFactoryServer.executor.AsyncExec(func() {
currentServerClient, _ := b.LoadOrStore(request.GetConnection().GetId(), eventFactoryServer)
if currentServerClient != eventFactoryServer {
currentEventFactoryServer, _ := b.LoadOrStore(request.GetConnection().GetId(), eventFactoryServer)
if currentEventFactoryServer != eventFactoryServer {
log.FromContext(ctx).Debug("recalling begin.Request because currentEventFactoryServer != eventFactoryServer")
conn, err = b.Request(ctx, request)
return
}
Expand Down

0 comments on commit 78d9292

Please sign in to comment.