From 7b6063d61f0a156bdd8034b2b760f3e1c39a71c0 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Wed, 27 Nov 2024 11:19:27 +1100 Subject: [PATCH 1/2] add healing to vl3 clients Signed-off-by: NikitaSkrynnik --- main.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 12d6436..4586cf6 100644 --- a/main.go +++ b/main.go @@ -43,10 +43,10 @@ import ( "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/vrf" "github.com/networkservicemesh/sdk/pkg/ipam/strictvl3ipam" "github.com/networkservicemesh/sdk/pkg/networkservice/chains/client" + "github.com/networkservicemesh/sdk/pkg/networkservice/common/begin" "github.com/networkservicemesh/sdk/pkg/networkservice/common/clientinfo" "github.com/networkservicemesh/sdk/pkg/networkservice/common/heal" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd" - "github.com/networkservicemesh/sdk/pkg/networkservice/common/null" "github.com/networkservicemesh/sdk/pkg/networkservice/common/onidle" "github.com/networkservicemesh/sdk/pkg/networkservice/common/retry" "github.com/networkservicemesh/sdk/pkg/networkservice/common/upstreamrefresh" @@ -96,6 +96,8 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" "github.com/networkservicemesh/sdk/pkg/tools/pprofutils" "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt" + + vppheal "github.com/networkservicemesh/sdk-vpp/pkg/tools/heal" ) // Config holds configuration parameters from environment variables @@ -120,9 +122,14 @@ type Config struct { LogLevel string `default:"INFO" desc:"Log level" split_words:"true"` PprofEnabled bool `default:"false" desc:"is pprof enabled" split_words:"true"` PprofListenOn string `default:"localhost:6060" desc:"pprof URL to ListenAndServe" split_words:"true"` - dnsServerAddr net.IP - dnsServerAddrCh chan net.IP - dnsConfigs genericsync.Map[string, []*networkservice.DNSConfig] + + LivenessCheckEnabled bool `default:"true" desc:"Dataplane liveness check enabled/disabled" split_words:"true"` + LivenessCheckInterval time.Duration `default:"1200ms" desc:"Dataplane liveness check interval" split_words:"true"` + LivenessCheckTimeout time.Duration `default:"1s" desc:"Dataplane liveness check timeout" split_words:"true"` + + dnsServerAddr net.IP + dnsServerAddrCh chan net.IP + dnsConfigs genericsync.Map[string, []*networkservice.DNSConfig] } // Process prints and processes env to config @@ -548,6 +555,13 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn ), ) + var healOptions = []heal.Option{heal.WithLivenessCheckInterval(config.LivenessCheckInterval), heal.WithLivenessCheckTimeout(config.LivenessCheckTimeout)} + if config.LivenessCheckEnabled { + healOptions = append(healOptions, heal.WithLivenessCheck(vppheal.VPPLivenessCheck(vppConn))) + } + + healClient := heal.NewClient(ctx, healOptions...) + c := client.NewClient( ctx, client.WithClientURL(&config.ConnectTo), @@ -570,10 +584,10 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn recvfd.NewClient(), )..., ), - client.WithHealClient(null.NewClient()), + client.WithHealClient(healClient), client.WithDialTimeout(config.DialTimeout), client.WithDialOptions(dialOptions...), - ) + client.WithReselectFunc(begin.ReselectWithSameEndpointFunc)) return retry.NewClient(c) } From f6840c9a01b04d72b875a9b821fc9cdeb31812aa Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Wed, 27 Nov 2024 11:22:15 +1100 Subject: [PATCH 2/2] fix CI issues Signed-off-by: NikitaSkrynnik --- README.md | 3 +++ internal/imports/imports_linux.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ec69a6..843f4c5 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,9 @@ docker build . * `NSM_LOG_LEVEL` - Log level (default: "INFO") * `NSM_PPROF_ENABLED` - is pprof enabled (default: "false") * `NSM_PPROF_LISTEN_ON` - pprof URL to ListenAndServe (default: "localhost:6060") +* `NSM_LIVENESS_CHECK_ENABLED` - Dataplane liveness check enabled/disabled (default: "true") +* `NSM_LIVENESS_CHECK_INTERVAL` - Dataplane liveness check interval (default: "1200ms") +* `NSM_LIVENESS_CHECK_TIMEOUT` - Dataplane liveness check timeout (default: "1s") # Testing diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 3d7b7a3..43d1229 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -21,17 +21,18 @@ import ( _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/tag" _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up" _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/vrf" + _ "github.com/networkservicemesh/sdk-vpp/pkg/tools/heal" _ "github.com/networkservicemesh/sdk/pkg/ipam/strictvl3ipam" _ "github.com/networkservicemesh/sdk/pkg/networkservice/chains/client" _ "github.com/networkservicemesh/sdk/pkg/networkservice/chains/endpoint" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize" + _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/begin" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/clientinfo" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/heal" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/kernel" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd" - _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/null" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/onidle" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/retry" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/upstreamrefresh"