From bc563e9838a3f8c2e55d5a258c61b7047ba5c104 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik <93182827+NikitaSkrynnik@users.noreply.github.com> Date: Tue, 26 Sep 2023 21:54:50 +1100 Subject: [PATCH] Enable vpp liveness check (#601) * enable vpp liveness check Signed-off-by: Nikita Skrynnik * fix CI Signed-off-by: Nikita Skrynnik * fix linter Signed-off-by: Nikita Skrynnik --------- Signed-off-by: Nikita Skrynnik --- go.mod | 4 ++-- go.sum | 8 ++++---- internal/imports/imports_linux.go | 1 + main.go | 27 ++++++++++++++++----------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 2cd1350..fc9442e 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/networkservicemesh/api v1.10.1-0.20230822145124-c4a3ece88804 github.com/networkservicemesh/sdk v0.5.1-0.20230922100610-97bacd7153a2 - github.com/networkservicemesh/sdk-vpp v0.0.0-20230919113300-d37df12b0ec6 + github.com/networkservicemesh/sdk-vpp v0.0.0-20230926095007-bdb84bc2eb73 github.com/networkservicemesh/vpphelper v0.0.0-20230901145133-a14aecebd1cb github.com/sirupsen/logrus v1.9.0 github.com/spiffe/go-spiffe/v2 v2.0.0 @@ -39,7 +39,7 @@ require ( github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/networkservicemesh/govpp v0.0.0-20230922102554-a46e6ced9b14 // indirect - github.com/networkservicemesh/sdk-kernel v0.0.0-20230919032839-76893a26b5c1 // indirect + github.com/networkservicemesh/sdk-kernel v0.0.0-20230922100857-9162d4c90b72 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.16.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect diff --git a/go.sum b/go.sum index 6a5451b..e79a865 100644 --- a/go.sum +++ b/go.sum @@ -133,10 +133,10 @@ github.com/networkservicemesh/govpp v0.0.0-20230922102554-a46e6ced9b14 h1:BlBHDA github.com/networkservicemesh/govpp v0.0.0-20230922102554-a46e6ced9b14/go.mod h1:uTpdzM7rhTAJG86sjt3dQcHVABUgohuZCAyGWX5Rfmo= github.com/networkservicemesh/sdk v0.5.1-0.20230922100610-97bacd7153a2 h1:zucewg+R+ik42Nc2r0MaUzz8kuGh4cJNZU1UqSbmQR0= github.com/networkservicemesh/sdk v0.5.1-0.20230922100610-97bacd7153a2/go.mod h1:KzbOZkk84r6KMNESKb50DpIWqxqCA88Mb+2jFrAdBJs= -github.com/networkservicemesh/sdk-kernel v0.0.0-20230919032839-76893a26b5c1 h1:el4UfXY1LkASWA9VG2PY6irUm67s/pIYl3bi+GVZkfg= -github.com/networkservicemesh/sdk-kernel v0.0.0-20230919032839-76893a26b5c1/go.mod h1:in+/IFCMBTAzrQ4Pp3L2F0NO+2A/7h+7wCizBHasr18= -github.com/networkservicemesh/sdk-vpp v0.0.0-20230919113300-d37df12b0ec6 h1:Q5+RBvvPMTnPiXvysxG7kCFSjScLuTtnOtTs3rxLefc= -github.com/networkservicemesh/sdk-vpp v0.0.0-20230919113300-d37df12b0ec6/go.mod h1:GUS/t3lMj4BvcKkDmnPuWLDz56SfMiqHR8CFzxRTBcU= +github.com/networkservicemesh/sdk-kernel v0.0.0-20230922100857-9162d4c90b72 h1:9v+iNAms4UjexCWFXsrbePQ5966+7X0UDy/Sh2xfixA= +github.com/networkservicemesh/sdk-kernel v0.0.0-20230922100857-9162d4c90b72/go.mod h1:zzkoj1RRFo0ESoamO0Vn8cawTiaNvHuK98+tRIehkcE= +github.com/networkservicemesh/sdk-vpp v0.0.0-20230926095007-bdb84bc2eb73 h1:o3fSnoUgNbU+iWgFkwF3daq4nF8Dg2jBhPrHhLxQzj0= +github.com/networkservicemesh/sdk-vpp v0.0.0-20230926095007-bdb84bc2eb73/go.mod h1:K2XS8LchbkmC63zvEvYRGoupcfBrkRPPGD/SOGW1s4U= github.com/networkservicemesh/vpphelper v0.0.0-20230901145133-a14aecebd1cb h1:SETtZ12eYPkUGafW1DwGb8kSOR8O4OniSuZnqn2bOOw= github.com/networkservicemesh/vpphelper v0.0.0-20230901145133-a14aecebd1cb/go.mod h1:gHuTaUs1uFvyOY0Cy9DXvyAR2MtwmlPD2NTyYfr6kLc= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 183e1df..0397c44 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -13,6 +13,7 @@ import ( _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/connectioncontext" _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/mechanisms/memif" _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up" + _ "github.com/networkservicemesh/sdk-vpp/pkg/tools/heal" _ "github.com/networkservicemesh/sdk/pkg/networkservice/chains/client" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/clientinfo" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/excludedprefixes" diff --git a/main.go b/main.go index bcc0e45..87a5ded 100644 --- a/main.go +++ b/main.go @@ -47,6 +47,7 @@ import ( "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/connectioncontext" "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/mechanisms/memif" "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up" + vppheal "github.com/networkservicemesh/sdk-vpp/pkg/tools/heal" "github.com/networkservicemesh/sdk/pkg/networkservice/chains/client" "github.com/networkservicemesh/sdk/pkg/networkservice/common/clientinfo" "github.com/networkservicemesh/sdk/pkg/networkservice/common/excludedprefixes" @@ -78,6 +79,10 @@ type Config struct { LogLevel string `default:"INFO" desc:"Log level" split_words:"true"` OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint"` MetricsExportInterval time.Duration `default:"10s" desc:"interval between mertics exports" split_words:"true"` + + LivenessCheckEnabled bool `default:"true" desc:"Dataplane liveness check enabled/disabled"` + LivenessCheckInterval time.Duration `default:"1200ms" desc:"Dataplane liveness check interval"` + LivenessCheckTimeout time.Duration `default:"1s" desc:"Dataplane liveness check timeout"` } func main() { @@ -188,24 +193,25 @@ func main() { dialOptions := append(tracing.WithTracingDial(), grpc.WithDefaultCallOptions( grpc.WaitForReady(true), - grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))), - ), + grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime)))), grpc.WithTransportCredentials( - grpcfd.TransportCredentials( - credentials.NewTLS( - tlsClientConfig, - ), - ), - ), + grpcfd.TransportCredentials(credentials.NewTLS(tlsClientConfig))), grpcfd.WithChainStreamInterceptor(), grpcfd.WithChainUnaryInterceptor(), ) + var healOptions = []heal.Option{heal.WithLivenessCheckInterval(config.LivenessCheckInterval), + heal.WithLivenessCheckTimeout(config.LivenessCheckTimeout)} + + if config.LivenessCheckEnabled { + healOptions = append(healOptions, heal.WithLivenessCheck(vppheal.VPPLivenessCheck(vppConn))) + } + nsmClient := client.NewClient( ctx, client.WithClientURL(&config.ConnectTo), client.WithName(config.Name), - client.WithHealClient(heal.NewClient(ctx)), + client.WithHealClient(heal.NewClient(ctx, healOptions...)), client.WithAdditionalFunctionality( clientinfo.NewClient(), upstreamrefresh.NewClient(ctx), @@ -214,8 +220,7 @@ func main() { memif.NewClient(ctx, vppConn), sendfd.NewClient(), recvfd.NewClient(), - excludedprefixes.NewClient(excludedprefixes.WithAwarenessGroups(config.AwarenessGroups)), - ), + excludedprefixes.NewClient(excludedprefixes.WithAwarenessGroups(config.AwarenessGroups))), client.WithDialTimeout(config.DialTimeout), client.WithDialOptions(dialOptions...), )