Skip to content

Commit

Permalink
Enable vpp liveness check (#601)
Browse files Browse the repository at this point in the history
* enable vpp liveness check

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* fix CI

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* fix linter

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

---------

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik authored Sep 26, 2023
1 parent f0897f4 commit bc563e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 16 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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),
Expand All @@ -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...),
)
Expand Down

0 comments on commit bc563e9

Please sign in to comment.