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

replace peers on peer/host update #491

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions functions/mqhandlers.go
mattkasun marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

@abhishek9686 abhishek9686 Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will solve the issue with peer deletions: gravitl/netmaker#2445
we shouldn't be replacing peers on every peer update, it will interfere with active connections, it's a costly operation it becomes more evident at scale
for your reference: https://github.com/WireGuard/wireguard-go/blob/469159ecf7d108dc1d44f8789dedbb463b7bd3a6/device/uapi.go#L243

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an interim fix until peer update refactor is complete

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR has the fixes needed: gravitl/netmaker#2445

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and peer update refactor won't go in until a couple of releases

Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func HostPeerUpdate(client mqtt.Client, msg mqtt.Message) {
currentGW6 := config.GW6Addr
isInetGW := config.UpdateHostPeers(peerUpdate.Peers)
_ = config.WriteNetclientConfig()
_ = wireguard.SetPeers(false)
_ = wireguard.SetPeers(true)
wireguard.GetInterface().GetPeerRoutes()
if err = routes.SetNetmakerPeerEndpointRoutes(config.Netclient().DefaultInterface); err != nil {
slog.Warn("error when setting peer routes after peer update", "error", err)
Expand Down Expand Up @@ -268,7 +268,7 @@ func HostUpdate(client mqtt.Client, msg mqtt.Message) {
return
}

if err = wireguard.SetPeers(false); err == nil {
if err = wireguard.SetPeers(true); err == nil {
if err = routes.SetNetmakerPeerEndpointRoutes(config.Netclient().DefaultInterface); err != nil {
slog.Error("error when setting peer routes after host update", "error", err)
}
Expand Down