Skip to content

Commit

Permalink
Fix endless waiting in liveness check (#788)
Browse files Browse the repository at this point in the history
* Add retry for routesClient + fix endless waiting in liveness check

Signed-off-by: Nikita Skrynnik <[email protected]>

* add more fixes to vpp liveness checker

Signed-off-by: Nikita Skrynnik <[email protected]>

* cleanup

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix golang linter

Signed-off-by: Nikita Skrynnik <[email protected]>

---------

Signed-off-by: Nikita Skrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik authored Dec 29, 2023
1 parent cfa86a7 commit 147ddfd
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions pkg/tools/heal/liveness_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,24 @@ const (
intervalFactor = 0.85
)

func waitForResponses(responseCh <-chan error) bool {
func waitForResponses(ctx context.Context, responseCh <-chan error) bool {
respCount := cap(responseCh)
success := true
for {
resp, ok := <-responseCh
if !ok {
select {
case <-ctx.Done():
return false
}
if resp != nil {
success = false
}
respCount--
if respCount == 0 {
return success
case resp, ok := <-responseCh:
if !ok {
return false
}
if resp != nil {
success = false
}
respCount--
if respCount == 0 {
return success
}
}
}
}
Expand Down Expand Up @@ -103,20 +107,18 @@ func doPing(
}
defer func() { _ = subscription.Unsubscribe() }()

for {
select {
case <-deadlineCtx.Done():
return
case rawMsg := <-notifCh:
if msg, ok := rawMsg.(*ping.PingFinishedEvent); ok {
if msg.ReplyCount == 0 {
err = errors.New("No packets received")
logger.Errorf(err.Error())
responseCh <- err
return
}
responseCh <- nil
select {
case <-deadlineCtx.Done():
return
case rawMsg := <-notifCh:
if msg, ok := rawMsg.(*ping.PingFinishedEvent); ok {
if msg.ReplyCount == 0 {
err = errors.New("No packets received")
logger.Errorf(err.Error())
responseCh <- err
return
}
responseCh <- nil
}
}
}
Expand Down Expand Up @@ -169,6 +171,6 @@ func VPPLivenessCheck(vppConn vpphelper.Connection) func(deadlineCtx context.Con
}

// Waiting for all ping results. If at least one fails - return false
return waitForResponses(responseCh)
return waitForResponses(deadlineCtx, responseCh)
}
}

0 comments on commit 147ddfd

Please sign in to comment.