Skip to content

Commit

Permalink
update grpcfd (#1640)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin committed Jul 1, 2024
1 parent 37ad693 commit 104b98b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
16 changes: 9 additions & 7 deletions pkg/networkservice/common/monitor/eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ func (cev *eventLoop) eventLoop() {
if err != nil {
// If we get an error, we've lost our connection... Send Down update
connOut := cev.conn.Clone()
connOut.State = networkservice.State_DOWN
eventOut := &networkservice.ConnectionEvent{
Type: networkservice.ConnectionEventType_UPDATE,
Connections: map[string]*networkservice.Connection{
cev.conn.GetId(): connOut,
},
if connOut != nil {
connOut.State = networkservice.State_DOWN
eventOut := &networkservice.ConnectionEvent{
Type: networkservice.ConnectionEventType_UPDATE,
Connections: map[string]*networkservice.Connection{
cev.conn.GetId(): connOut,
},
}
_ = cev.eventConsumer.Send(eventOut)
}
_ = cev.eventConsumer.Send(eventOut)
return
}
_ = cev.eventConsumer.Send(eventIn)
Expand Down
30 changes: 15 additions & 15 deletions pkg/networkservice/common/monitor/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ import (
"context"

"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/clientconn"
"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
"github.com/networkservicemesh/sdk/pkg/tools/postpone"

"github.com/networkservicemesh/api/pkg/api/networkservice"

Expand Down Expand Up @@ -58,7 +55,7 @@ func NewServer(chainCtx context.Context, monitorServerPtr *networkservice.Monito
}

func (m *monitorServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) {
closeCtxFunc := postpone.ContextWithValues(ctx)
// closeCtxFunc := postpone.ContextWithValues(ctx)
// Cancel any existing eventLoop
cancelEventLoop, loaded := loadAndDelete(ctx, metadata.IsClient(m))
if loaded {
Expand Down Expand Up @@ -86,17 +83,20 @@ func (m *monitorServer) Request(ctx context.Context, request *networkservice.Net

// If we have a clientconn ... we must be part of a passthrough server, and have a client to pass
// events through from, so start an eventLoop
cc, ccLoaded := clientconn.Load(ctx)
if ccLoaded {
cancelEventLoop, eventLoopErr := newEventLoop(m.chainCtx, m.MonitorConnectionServer.(EventConsumer), cc, conn)
if eventLoopErr != nil {
closeCtx, closeCancel := closeCtxFunc()
defer closeCancel()
_, _ = next.Client(closeCtx).Close(closeCtx, conn)
return nil, errors.Wrap(eventLoopErr, "unable to monitor")
}
store(ctx, metadata.IsClient(m), cancelEventLoop)
}
// cc, ccLoaded := clientconn.Load(ctx)
// log.FromContext(ctx).Infof("ccLoaded")
// if ccLoaded {
// log.FromContext(ctx).Infof("newEventLoop")
// cancelEventLoop, eventLoopErr := newEventLoop(m.chainCtx, m.MonitorConnectionServer.(EventConsumer), cc, conn)
// if eventLoopErr != nil {
// closeCtx, closeCancel := closeCtxFunc()
// defer closeCancel()
// _, _ = next.Client(closeCtx).Close(closeCtx, conn)
// return nil, errors.Wrap(eventLoopErr, "unable to monitor")
// }
// log.FromContext(ctx).Infof("STORE")
// store(ctx, metadata.IsClient(m), cancelEventLoop)
// }

return conn, nil
}
Expand Down
11 changes: 9 additions & 2 deletions pkg/networkservice/common/updatepath/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ func (i *updatePathClient) Request(ctx context.Context, request *networkservice.
return nil, err
}

conn.Id = conn.Path.PathSegments[index].Id
conn.Path.Index = index
segments := conn.GetPath().GetPathSegments()
if segments != nil && len(segments) > int(index) {
conn.Id = segments[index].Id
}

path := conn.GetPath()
if path != nil {
path.Index = index
}

return conn, nil
}
Expand Down

0 comments on commit 104b98b

Please sign in to comment.