Skip to content

Commit

Permalink
update grpcfd (networkservicemesh#1640)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Tingaikin <[email protected]>
  • Loading branch information
denis-tingaikin authored and NikitaSkrynnik committed Oct 7, 2024
1 parent b7dcbce commit c3c0f15
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
17 changes: 10 additions & 7 deletions pkg/networkservice/common/monitor/eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ func (cev *eventLoop) eventLoop() {
connOut := cev.conn.Clone()
if err != nil && connOut != nil {
// If we get an error, we've lost our connection... Send Down update
connOut.State = networkservice.State_DOWN
eventOut := &networkservice.ConnectionEvent{
Type: networkservice.ConnectionEventType_UPDATE,
Connections: map[string]*networkservice.Connection{
cev.conn.GetId(): connOut,
},
connOut := cev.conn.Clone()
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
21 changes: 15 additions & 6 deletions pkg/networkservice/common/monitor/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

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

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

"github.com/networkservicemesh/api/pkg/api/networkservice"
Expand Down Expand Up @@ -56,6 +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)
// Cancel any existing eventLoop
cancelEventLoop, loaded := loadAndDelete(ctx, metadata.IsClient(m))
if loaded {
Expand Down Expand Up @@ -83,11 +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 := newEventLoop(m.chainCtx, m.MonitorConnectionServer.(EventConsumer), cc, conn)
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: 8 additions & 3 deletions pkg/networkservice/common/updatepath/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ func (i *updatePathClient) Request(ctx context.Context, request *networkservice.
return nil, err
}

if conn.GetPath() != nil && len(conn.GetPath().GetPathSegments()) > int(index) {
conn.Id = conn.GetPath().GetPathSegments()[index].Id
conn.GetPath().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 c3c0f15

Please sign in to comment.