From 4d4101917c0ea4e42030af5cb3aadbd942b8129c Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik <93182827+NikitaSkrynnik@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:16:06 +1100 Subject: [PATCH] Update vpphelper manually (#1213) Signed-off-by: NikitaSkrynnik --- README.md | 1 + go.mod | 2 +- go.sum | 4 ++-- internal/config/config.go | 11 ++++++----- internal/imports/imports_linux.go | 1 + internal/tests/suite_ipsec_test.go | 11 +++++------ internal/tests/suite_memif_test.go | 8 +++----- internal/tests/suite_setup_test.go | 5 +++-- internal/tests/suite_test.go | 9 ++++----- internal/tests/suite_wireguard_test.go | 11 +++++------ main.go | 5 ++++- 11 files changed, 35 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 5986204c..3466fa4d 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ docker build . * `NSM_VPP_API_SOCKET` - filename of socket to connect to existing VPP instance. * `NSM_VPP_INIT` - type of VPP initialization. Must be AF_XDP, AF_PACKET or NONE * `NSM_VPP_INIT_PARAMS` - Configuration file path containing VPP API parameters for initialization +* `NSM_VPP_MIN_OPERATION_TIMEOUT` - minimum timeout for every vpp operation * `NSM_RESOURCE_POLL_TIMEOUT` - device plugin polling timeout * `NSM_DEVICE_PLUGIN_PATH` - path to the device plugin directory * `NSM_POD_RESOURCES_PATH` - path to the pod resources directory diff --git a/go.mod b/go.mod index 4983077e..1aaa75e6 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/networkservicemesh/sdk-kernel v0.0.0-20241126090835-89a3b4302060 github.com/networkservicemesh/sdk-sriov v0.0.0-20241126091246-f52c0d79803b github.com/networkservicemesh/sdk-vpp v0.0.0-20241106142209-3dbe273c826b - github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6 + github.com/networkservicemesh/vpphelper v0.0.0-20241128104352-f48814525b60 github.com/pkg/errors v0.9.1 github.com/safchain/ethtool v0.3.0 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 18ee40b2..6c72f0ba 100644 --- a/go.sum +++ b/go.sum @@ -166,8 +166,8 @@ github.com/networkservicemesh/sdk-sriov v0.0.0-20241126091246-f52c0d79803b h1:G+ github.com/networkservicemesh/sdk-sriov v0.0.0-20241126091246-f52c0d79803b/go.mod h1:CEKlRXbbf4rJzk3gMoPOPebIHu+Vmf529uhQK3O1gdw= github.com/networkservicemesh/sdk-vpp v0.0.0-20241106142209-3dbe273c826b h1:oB4ZLVpDYcXF5F6gDh0NwZff3Nei3UONyzwn+FXSkZg= github.com/networkservicemesh/sdk-vpp v0.0.0-20241106142209-3dbe273c826b/go.mod h1:vXXFWTK5XHuuKUY07lY+rdmNi8w7l2F34nEQRLtC3EA= -github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6 h1:o+enN5yCikNXZN+hO+JjE+aLxBWq9+GMVF9GSQtpwMI= -github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6/go.mod h1:n6+8PnoDvWj6WMryfU3J8HOCusgysFjQ0kGLfrcsDEM= +github.com/networkservicemesh/vpphelper v0.0.0-20241128104352-f48814525b60 h1:Yx5Do9XvsfY0S7d6yh7msHA+LdniP9JfYt+KgaWkEfA= +github.com/networkservicemesh/vpphelper v0.0.0-20241128104352-f48814525b60/go.mod h1:Qc5x5poZk5cVzcHk4ZIL6+NMC95uoitsmmnl7X9V/Yw= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/open-policy-agent/opa v0.44.0 h1:sEZthsrWBqIN+ShTMJ0Hcz6a3GkYsY4FaB2S/ou2hZk= diff --git a/internal/config/config.go b/internal/config/config.go index 32e6cb22..dcc43c82 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -52,11 +52,12 @@ type Config struct { PrometheusListenOn string `default:":8081" desc:"Prometheus URL to ListenAndServe" split_words:"true"` PrometheusServerHeaderTimeout time.Duration `default:"5s" desc:"Timeout for how long the Prometheus server waits for complete request headers from the client" 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"` - VppAPISocket string `default:"/var/run/vpp/external/vpp-api.sock" desc:"filename of socket to connect to existing VPP instance. If empty a VPP instance is run in forwarder" split_words:"true"` - VppInit vppinit.Func `default:"AF_PACKET" desc:"type of VPP initialization. Must be AF_XDP, AF_PACKET or NONE" split_words:"true"` - VppInitParams string `desc:"Configuration file path containing VPP API parameters for initialization" 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"` + VppAPISocket string `default:"/var/run/vpp/external/vpp-api.sock" desc:"filename of socket to connect to existing VPP instance. If empty a VPP instance is run in forwarder" split_words:"true"` + VppInit vppinit.Func `default:"AF_PACKET" desc:"type of VPP initialization. Must be AF_XDP, AF_PACKET or NONE" split_words:"true"` + VppInitParams string `desc:"Configuration file path containing VPP API parameters for initialization" split_words:"true"` + VPPMinOperationTimeout time.Duration `default:"2s" desc:"minimum timeout for every vpp operation" split_words:"true"` ResourcePollTimeout time.Duration `default:"30s" desc:"device plugin polling timeout" split_words:"true"` DevicePluginPath string `default:"/var/lib/kubelet/device-plugins/" desc:"path to the device plugin directory" split_words:"true"` diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 6467636e..17fabd11 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -92,6 +92,7 @@ import ( _ "github.com/networkservicemesh/sdk/pkg/tools/token" _ "github.com/networkservicemesh/sdk/pkg/tools/tracing" _ "github.com/networkservicemesh/vpphelper" + _ "github.com/networkservicemesh/vpphelper/extendtimeout" _ "github.com/pkg/errors" _ "github.com/safchain/ethtool" _ "github.com/sirupsen/logrus" diff --git a/internal/tests/suite_ipsec_test.go b/internal/tests/suite_ipsec_test.go index e4d17eb0..17a707c1 100644 --- a/internal/tests/suite_ipsec_test.go +++ b/internal/tests/suite_ipsec_test.go @@ -24,10 +24,9 @@ import ( "context" "net" + "go.fd.io/govpp/api" "google.golang.org/grpc" - "github.com/networkservicemesh/vpphelper" - "github.com/networkservicemesh/api/pkg/api/networkservice" ipsecapi "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/ipsec" @@ -47,14 +46,14 @@ import ( type ipsecVerifiableEndpoint struct { ctx context.Context - vppConn vpphelper.Connection + vppConn api.Connection endpoint.Endpoint } func newIpsecVerifiableEndpoint(ctx context.Context, prefix1, prefix2 *net.IPNet, tokenGenerator token.GeneratorFunc, - vppConn vpphelper.Connection) verifiableEndpoint { + vppConn api.Connection) verifiableEndpoint { rv := &ipsecVerifiableEndpoint{ ctx: ctx, vppConn: vppConn, @@ -94,14 +93,14 @@ func (v *ipsecVerifiableEndpoint) VerifyClose(_ *networkservice.Connection) erro type ipsecVerifiableClient struct { ctx context.Context - vppConn vpphelper.Connection + vppConn api.Connection networkservice.NetworkServiceClient } func newIpsecVerifiableClient( ctx context.Context, sutCC grpc.ClientConnInterface, - vppConn vpphelper.Connection, + vppConn api.Connection, ) verifiableClient { return &ipsecVerifiableClient{ ctx: ctx, diff --git a/internal/tests/suite_memif_test.go b/internal/tests/suite_memif_test.go index be80efe8..37c2844b 100644 --- a/internal/tests/suite_memif_test.go +++ b/internal/tests/suite_memif_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023 Cisco and/or its affiliates. +// Copyright (c) 2020-2024 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -29,8 +29,6 @@ import ( "go.fd.io/govpp/api" "go.fd.io/govpp/binapi/vlib" - "github.com/networkservicemesh/vpphelper" - "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd" "github.com/networkservicemesh/sdk/pkg/networkservice/core/chain" @@ -63,7 +61,7 @@ type memifVerifiableEndpoint struct { func newMemifVerifiableEndpoint(ctx context.Context, prefix1, prefix2 *net.IPNet, tokenGenerator token.GeneratorFunc, - vppConn vpphelper.Connection, + vppConn api.Connection, ) verifiableEndpoint { return &memifVerifiableEndpoint{ ctx: ctx, @@ -110,7 +108,7 @@ type memifVerifiableClient struct { networkservice.NetworkServiceClient } -func newMemifVerifiableClient(ctx context.Context, sutCC grpc.ClientConnInterface, vppConn vpphelper.Connection) verifiableClient { +func newMemifVerifiableClient(ctx context.Context, sutCC grpc.ClientConnInterface, vppConn api.Connection) verifiableClient { rv := &memifVerifiableClient{ ctx: ctx, vppConn: vppConn, diff --git a/internal/tests/suite_setup_test.go b/internal/tests/suite_setup_test.go index b0d264bd..36bb04e9 100644 --- a/internal/tests/suite_setup_test.go +++ b/internal/tests/suite_setup_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023 Cisco and/or its affiliates. +// Copyright (c) 2020-2024 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -32,6 +32,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" "github.com/spiffe/go-spiffe/v2/workloadapi" + "go.fd.io/govpp/api" "go.fd.io/govpp/binapi/vpe" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -204,7 +205,7 @@ func (f *ForwarderTestSuite) SetupSuite() { // ******************************************************************************** } -func (f *ForwarderTestSuite) createVpp(ctx context.Context, name string) (vppConn vpphelper.Connection, vppRoot string, errCh <-chan error) { +func (f *ForwarderTestSuite) createVpp(ctx context.Context, name string) (vppConn api.Connection, vppRoot string, errCh <-chan error) { now := time.Now() var err error vppRoot, err = os.MkdirTemp("", fmt.Sprintf("%s-", name)) diff --git a/internal/tests/suite_test.go b/internal/tests/suite_test.go index 629cdc8f..33b3163b 100644 --- a/internal/tests/suite_test.go +++ b/internal/tests/suite_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023 Cisco and/or its affiliates. +// Copyright (c) 2020-2024 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -25,10 +25,9 @@ import ( "github.com/spiffe/go-spiffe/v2/bundle/x509bundle" "github.com/spiffe/go-spiffe/v2/svid/x509svid" "github.com/stretchr/testify/suite" + "go.fd.io/govpp/api" "google.golang.org/grpc" - "github.com/networkservicemesh/vpphelper" - "github.com/networkservicemesh/api/pkg/api/registry" "github.com/networkservicemesh/cmd-forwarder-vpp/internal/config" @@ -51,12 +50,12 @@ type ForwarderTestSuite struct { x509bundle x509bundle.Source // vppServer stuff - vppServerConn vpphelper.Connection + vppServerConn api.Connection vppServerRoot string vppServerErrCh <-chan error // vppClient stuff - vppClientConn vpphelper.Connection + vppClientConn api.Connection vppClientRoot string vppClientErrCh <-chan error diff --git a/internal/tests/suite_wireguard_test.go b/internal/tests/suite_wireguard_test.go index 8baf1c47..e06d78c8 100644 --- a/internal/tests/suite_wireguard_test.go +++ b/internal/tests/suite_wireguard_test.go @@ -24,10 +24,9 @@ import ( "context" "net" + "go.fd.io/govpp/api" "google.golang.org/grpc" - "github.com/networkservicemesh/vpphelper" - "github.com/networkservicemesh/sdk/pkg/networkservice/chains/client" "github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize" @@ -48,14 +47,14 @@ import ( type wireguardVerifiableEndpoint struct { ctx context.Context - vppConn vpphelper.Connection + vppConn api.Connection endpoint.Endpoint } func newWireguardVerifiableEndpoint(ctx context.Context, prefix1, prefix2 *net.IPNet, tokenGenerator token.GeneratorFunc, - vppConn vpphelper.Connection) verifiableEndpoint { + vppConn api.Connection) verifiableEndpoint { rv := &wireguardVerifiableEndpoint{ ctx: ctx, vppConn: vppConn, @@ -95,14 +94,14 @@ func (v *wireguardVerifiableEndpoint) VerifyClose(_ *networkservice.Connection) type wireguardVerifiableClient struct { ctx context.Context - vppConn vpphelper.Connection + vppConn api.Connection networkservice.NetworkServiceClient } func newWireguardVerifiableClient( ctx context.Context, sutCC grpc.ClientConnInterface, - vppConn vpphelper.Connection, + vppConn api.Connection, ) verifiableClient { return &wireguardVerifiableClient{ ctx: ctx, diff --git a/main.go b/main.go index 85f10335..22712316 100644 --- a/main.go +++ b/main.go @@ -36,10 +36,12 @@ import ( "github.com/spiffe/go-spiffe/v2/spiffeid" "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" "github.com/spiffe/go-spiffe/v2/workloadapi" + "go.fd.io/govpp/api" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "github.com/networkservicemesh/vpphelper" + "github.com/networkservicemesh/vpphelper/extendtimeout" registryapi "github.com/networkservicemesh/api/pkg/api/registry" "github.com/networkservicemesh/sdk-k8s/pkg/tools/deviceplugin" @@ -174,7 +176,7 @@ func main() { // ******************************************************************************** now = time.Now() - var vppConn vpphelper.Connection + var vppConn api.Connection var vppErrCh <-chan error var metricsOpts []metrics.Option cleanupDoneCh := make(chan struct{}) @@ -202,6 +204,7 @@ func main() { log.FromContext(ctx).Info("local vpp is being used") } + vppConn = extendtimeout.NewConnection(vppConn, cfg.VPPMinOperationTimeout) log.FromContext(ctx).WithField("duration", time.Since(now)).Info("completed phase 2: run vpp and get a connection to it") // ********************************************************************************