Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add healing to vl3 clients #382

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion internal/imports/imports_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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)
}
Expand Down
Loading