From 273c97bab5544bcb2918de4ed7519297e09f77e6 Mon Sep 17 00:00:00 2001 From: Denis Tingaikin <49399980+denis-tingaikin@users.noreply.github.com> Date: Thu, 11 Nov 2021 02:47:05 +0300 Subject: [PATCH] add dialTimeout for cmd-forwarder-vpp (#393) Signed-off-by: denis-tingaikin --- go.mod | 2 +- go.sum | 4 ++-- internal/config/config.go | 1 + internal/xconnectns/server.go | 4 +++- main.go | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 75443033..51f394b2 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/networkservicemesh/sdk v0.5.1-0.20211110200317-2272de7cade7 github.com/networkservicemesh/sdk-k8s v0.0.0-20211103091718-33b5af79cf03 github.com/networkservicemesh/sdk-sriov v0.0.0-20211103092011-23a720ab62a6 - github.com/networkservicemesh/sdk-vpp v0.0.0-20211110200900-b81956c63fbd + github.com/networkservicemesh/sdk-vpp v0.0.0-20211110233207-dd1c00b6ebb2 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.7.0 github.com/spiffe/go-spiffe/v2 v2.0.0-beta.2 diff --git a/go.sum b/go.sum index 72e72383..f3af6051 100644 --- a/go.sum +++ b/go.sum @@ -358,8 +358,8 @@ github.com/networkservicemesh/sdk-kernel v0.0.0-20211110200529-c70dbe94eb13 h1:P github.com/networkservicemesh/sdk-kernel v0.0.0-20211110200529-c70dbe94eb13/go.mod h1:Oz6lGHKKSFyJXcTql3dRfufM8k/4idlQ5A4Do+DdbBE= github.com/networkservicemesh/sdk-sriov v0.0.0-20211103092011-23a720ab62a6 h1:WsnwJeTDbTVJc8FuCYIUt6y9QnYaRrEyH3TCycQGDRo= github.com/networkservicemesh/sdk-sriov v0.0.0-20211103092011-23a720ab62a6/go.mod h1:Sx4W7rd93sUhpCPT92FvhDXAbbfshVcB4IX4CgTrFos= -github.com/networkservicemesh/sdk-vpp v0.0.0-20211110200900-b81956c63fbd h1:+I9jnfpRWiv23Q9r5zGfBUi4CTwqjx3V29KmMUpOcuY= -github.com/networkservicemesh/sdk-vpp v0.0.0-20211110200900-b81956c63fbd/go.mod h1:6blhu3JzeEHEOeA8lUhQ4JYHUOB0xthiiaZEuTQ71NI= +github.com/networkservicemesh/sdk-vpp v0.0.0-20211110233207-dd1c00b6ebb2 h1:USJRlkP9tYXpzqxjx88edzqUDrTwyuuwe4aN/oat2q8= +github.com/networkservicemesh/sdk-vpp v0.0.0-20211110233207-dd1c00b6ebb2/go.mod h1:6blhu3JzeEHEOeA8lUhQ4JYHUOB0xthiiaZEuTQ71NI= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= diff --git a/internal/config/config.go b/internal/config/config.go index 29f2b7fe..9fc7cd49 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -40,6 +40,7 @@ type Config struct { ListenOn url.URL `default:"unix:///listen.on.socket" desc:"url to listen on" split_words:"true"` MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"` LogLevel string `default:"INFO" desc:"Log level" split_words:"true"` + DialTimeout time.Duration `default:"50ms" desc:"Timeout for the dial the next endpoint" split_words:"true"` TunnelIP net.IP `desc:"IP to use for tunnels" split_words:"true"` VxlanPort uint16 `default:"0" desc:"VXLAN port to use" split_words:"true"` diff --git a/internal/xconnectns/server.go b/internal/xconnectns/server.go index 876fb072..b4bd600d 100644 --- a/internal/xconnectns/server.go +++ b/internal/xconnectns/server.go @@ -23,6 +23,7 @@ import ( "context" "net" "net/url" + "time" "google.golang.org/grpc" @@ -58,9 +59,10 @@ func NewServer( sriovConfig *sriovconfig.Config, vfioDir, cgroupBaseDir string, clientURL *url.URL, + dialTimeout time.Duration, clientDialOptions ...grpc.DialOption, ) endpoint.Endpoint { - vppForwarder := vppforwarder.NewServer(ctx, name, authzServer, tokenGenerator, clientURL, vppConn, tunnelIP, tunnelPort, clientDialOptions...) + vppForwarder := vppforwarder.NewServer(ctx, name, authzServer, tokenGenerator, clientURL, vppConn, tunnelIP, tunnelPort, dialTimeout, clientDialOptions...) if sriovConfig == nil { return vppForwarder } diff --git a/main.go b/main.go index 028ad535..2dc8bd42 100644 --- a/main.go +++ b/main.go @@ -186,6 +186,7 @@ func main() { sriovConfig, cfg.VFIOPath, cfg.CgroupPath, &cfg.ConnectTo, + cfg.DialTimeout, grpc.WithTransportCredentials( grpcfd.TransportCredentials(credentials.NewTLS(tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny())))), grpc.WithDefaultCallOptions(