From 59fd2ef8e2c640e736f9bfd9c3ce30e6665ad01f Mon Sep 17 00:00:00 2001 From: anastasia-malysheva <81400483+anastasia-malysheva@users.noreply.github.com> Date: Fri, 29 Jul 2022 16:48:10 +0700 Subject: [PATCH] fix problem with monitor connection (#473) Signed-off-by: anastasia.malysheva --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 08f6a4f..8147e4e 100644 --- a/main.go +++ b/main.go @@ -246,7 +246,7 @@ func main() { u := nsurl.NSURL(config.NetworkServices[i]) id := fmt.Sprintf("%s-%d", config.Name, i) - + var monitoredConnections map[string]*networkservice.Connection monitorCtx, cancelMonitor := context.WithTimeout(signalCtx, config.RequestTimeout) defer cancelMonitor() @@ -258,12 +258,14 @@ func main() { }, }) if err != nil { - log.FromContext(ctx).Fatal(err.Error()) + log.FromContext(ctx).Fatalf("error from monitorConnectionClient", err.Error()) } event, err := stream.Recv() if err != nil { - log.FromContext(ctx).Fatal(err.Error()) + log.FromContext(ctx).Errorf("error from monitorConnection stream", err.Error()) + } else { + monitoredConnections = event.Connections } cancelMonitor() @@ -282,7 +284,7 @@ func main() { }, } - for _, conn := range event.Connections { + for _, conn := range monitoredConnections { path := conn.GetPath() if path.Index == 1 && path.PathSegments[0].Id == id && conn.Mechanism.Type == u.Mechanism().Type { request.Connection = conn