Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client/internal/routemanager/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ func (w *Watcher) recalculateRoutes(rsn reason, routerPeerStatuses map[route.ID]
return nil
}

if isRouteStickyOnFailure() {
log.Warnf("No available routes for network [%v], keep current route %s", w.handler, w.currentChosen.Peer)
return nil
}

if err := w.removeAllowedIPs(w.currentChosen, rsn); err != nil {
return fmt.Errorf("remove obsolete: %w", err)
}
Expand Down
24 changes: 24 additions & 0 deletions client/internal/routemanager/client/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package client

import (
"os"
"strings"

log "github.com/sirupsen/logrus"
)

const (
// envRouteStickyOnFailure is used to configure if routes should be kept on failure
envRouteStickyOnFailure = "NB_ROUTE_STICKY_ON_FAILURE"
)

// isRouteStickyOnFailure checks if routes should be kept on failure
func isRouteStickyOnFailure() bool {
stickyOnFailureEnv := os.Getenv(envRouteStickyOnFailure)
if stickyOnFailureEnv == "" {
return false
}

log.Infof("routes will be kept on failure as %s is set to %s", envRouteStickyOnFailure, stickyOnFailureEnv)
return strings.ToLower(stickyOnFailureEnv) == "true"
}
Loading