Skip to content

Commit

Permalink
add check for mechanism
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed May 5, 2022
1 parent b3ec72b commit f9457e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 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 @@ -35,6 +36,10 @@ const (
// NewKernelLivenessCheck 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 {
if mechanism := kernel.ToMechanism(conn.GetMechanism()); mechanism == nil {
log.FromContext(deadlineCtx).Errorf("Ping failed: wrong mechanism type")
}

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

0 comments on commit f9457e1

Please sign in to comment.