Skip to content

Commit

Permalink
Remove deprecated API for watching VPPAPI events (#798)
Browse files Browse the repository at this point in the history
* add watcher

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

* remove deprecated API from wireguard

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

* fix golangci linter

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

* go mod tidy

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

* delete more of deprecated API

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

* fix go linter issues

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

---------

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Feb 29, 2024
1 parent e7592de commit 4e554ca
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions pkg/tools/heal/liveness_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/govpp/binapi/ip_types"
"github.com/networkservicemesh/govpp/binapi/ping"
"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"
"go.fd.io/govpp/api"
Expand Down Expand Up @@ -62,16 +63,6 @@ func doPing(
responseCh chan bool) {
logger := log.FromContext(deadlineCtx).WithField("srcIP", srcIP.String()).WithField("dstIP", dstIP.String())

if _, err := ping.NewServiceClient(vppConn).WantPingFinishedEvents(deadlineCtx, &ping.WantPingFinishedEvents{
Address: dstIP,
Interval: interval,
Repeat: repeat,
}); err != nil {
logger.Error(errors.Wrap(err, "vppapi WantPingEvents returned error"))
responseCh <- true
return
}

watcher, err := vppConn.WatchEvent(deadlineCtx, &ping.PingFinishedEvent{})
if err != nil {
logger.Error(errors.Wrap(err, "failed to watch ping.PingFinishedEvent").Error())
Expand All @@ -81,6 +72,23 @@ func doPing(

defer func() { watcher.Close() }()

ifindex, ok := ifindex.Load(deadlineCtx, true)
if !ok {
logger.Errorf("failed to load ifindex")
responseCh <- true
return
}
if _, err := ping.NewServiceClient(vppConn).WantPingFinishedEvents(deadlineCtx, &ping.WantPingFinishedEvents{
Address: dstIP,
SwIfIndex: ifindex,

Check failure on line 83 in pkg/tools/heal/liveness_check.go

View workflow job for this annotation

GitHub Actions / build-and-test / build-and-test (ubuntu-latest)

unknown field SwIfIndex in struct literal of type ping.WantPingFinishedEvents

Check failure on line 83 in pkg/tools/heal/liveness_check.go

View workflow job for this annotation

GitHub Actions / golangci-lint / golangci-lint

unknown field SwIfIndex in struct literal of type ping.WantPingFinishedEvents (typecheck)
Interval: interval,
Repeat: repeat,
}); err != nil {
logger.Error(errors.Wrap(err, "vppapi WantPingEvents returned error"))
responseCh <- true
return
}

select {
case <-deadlineCtx.Done():
responseCh <- true
Expand Down

0 comments on commit 4e554ca

Please sign in to comment.