Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #3219

Merged
merged 4 commits into from
Nov 23, 2024
Merged

Master #3219

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
8 changes: 8 additions & 0 deletions pro/controllers/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ func failOverME(w http.ResponseWriter, r *http.Request) {
)
return
}
if peerNode.IsFailOver {
logic.ReturnErrorResponse(
w,
r,
logic.FormatError(errors.New("peer is acting as failover"), "badrequest"),
)
return
}
if node.IsRelayed && node.RelayedBy == peerNode.ID.String() {
logic.ReturnErrorResponse(
w,
Expand Down
6 changes: 5 additions & 1 deletion pro/logic/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package logic
import (
"errors"
"net"
"sync"

"github.com/google/uuid"
"github.com/gravitl/netmaker/logger"
Expand All @@ -11,8 +12,11 @@ import (
"golang.org/x/exp/slog"
)

func SetFailOverCtx(failOverNode, victimNode, peerNode models.Node) error {
var failOverCtxMutex = &sync.RWMutex{}

func SetFailOverCtx(failOverNode, victimNode, peerNode models.Node) error {
failOverCtxMutex.Lock()
defer failOverCtxMutex.Unlock()
if peerNode.FailOverPeers == nil {
peerNode.FailOverPeers = make(map[string]struct{})
}
Expand Down
Loading