Skip to content

Commit

Permalink
Merge pull request #382 from NikitaSkrynnik/heal
Browse files Browse the repository at this point in the history
Add healing to vl3 clients
  • Loading branch information
denis-tingaikin authored Nov 27, 2024
2 parents 13839be + f6840c9 commit afea49f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
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

0 comments on commit afea49f

Please sign in to comment.