Skip to content

Commit

Permalink
Merge pull request #458 from NikitaSkrynnik/fix-liveness-check
Browse files Browse the repository at this point in the history
[qfix] Add check for mechanism in NewKernelLivenessCheck func
  • Loading branch information
denis-tingaikin authored May 5, 2022
2 parents b3ec72b + 46f009a commit cd6d515
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/kernel/tools/heal/liveness_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/tatsushid/go-fastping"
)
Expand All @@ -32,9 +33,14 @@ const (
defaultTimeout = 200 * time.Millisecond
)

// NewKernelLivenessCheck is an implementation of heal.LivenessCheck. It sends ICMP
// KernelLivenessCheck is an implementation of heal.LivenessCheck. It sends ICMP
// ping and checks reply. Returns false if didn't get reply.
func NewKernelLivenessCheck(deadlineCtx context.Context, conn *networkservice.Connection) bool {
func KernelLivenessCheck(deadlineCtx context.Context, conn *networkservice.Connection) bool {
if mechanism := conn.GetMechanism().GetType(); mechanism != kernel.MECHANISM {
log.FromContext(deadlineCtx).Warnf("ping is not supported for mechanism %v", mechanism)
return true
}

p := fastping.NewPinger()
deadline, ok := deadlineCtx.Deadline()
if !ok {
Expand Down

0 comments on commit cd6d515

Please sign in to comment.