mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
debug
This commit is contained in:
parent
2a4a30f937
commit
36b319c772
5 changed files with 14 additions and 14 deletions
|
@ -406,7 +406,7 @@ func createNode(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = runServerPeerUpdate(node.Network, isServer(&node)); err != nil {
|
||||
if err = runServerPeerUpdate(node.Network, isServer(&node), "node create"); err != nil {
|
||||
logger.Log(1, "internal error when creating node:", node.ID)
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ func uncordonNode(w http.ResponseWriter, r *http.Request) {
|
|||
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||
return
|
||||
}
|
||||
if err = runServerPeerUpdate(node.Network, isServer(&node)); err != nil {
|
||||
if err = runServerPeerUpdate(node.Network, isServer(&node), "node uncordon"); err != nil {
|
||||
logger.Log(1, "internal error when approving node:", nodeid)
|
||||
}
|
||||
go func() {
|
||||
|
@ -458,7 +458,7 @@ func createEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|||
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||
return
|
||||
}
|
||||
if err = runServerPeerUpdate(gateway.NetID, isServer(&node)); err != nil {
|
||||
if err = runServerPeerUpdate(gateway.NetID, isServer(&node), "node egress create"); err != nil {
|
||||
logger.Log(1, "internal error when setting peers after creating egress on node:", gateway.NodeID)
|
||||
}
|
||||
go func() {
|
||||
|
@ -484,7 +484,7 @@ func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|||
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||
return
|
||||
}
|
||||
if err = runServerPeerUpdate(netid, isServer(&node)); err != nil {
|
||||
if err = runServerPeerUpdate(netid, isServer(&node), "egress delete"); err != nil {
|
||||
logger.Log(1, "internal error when setting peers after removing egress on node:", nodeid)
|
||||
}
|
||||
go func() {
|
||||
|
@ -604,7 +604,7 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
|
|||
err = logic.SetDNS()
|
||||
}
|
||||
|
||||
err = runServerPeerUpdate(node.Network, shouldPeersUpdate)
|
||||
err = runServerPeerUpdate(node.Network, shouldPeersUpdate, "node update")
|
||||
if err != nil {
|
||||
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||
return
|
||||
|
@ -642,7 +642,7 @@ func deleteNode(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
err = runServerPeerUpdate(node.Network, isServer(&node))
|
||||
err = runServerPeerUpdate(node.Network, isServer(&node), "node delete")
|
||||
if err != nil {
|
||||
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||
return
|
||||
|
|
|
@ -97,7 +97,7 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.Object)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = runServerPeerUpdate(node.Network, isServer(&node))
|
||||
err = runServerPeerUpdate(node.Network, isServer(&node), "node_grpc create")
|
||||
if err != nil {
|
||||
logger.Log(1, "internal error when setting peers after node,", node.ID, "was created (gRPC)")
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.Object)
|
|||
if errN != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = runServerPeerUpdate(newnode.Network, shouldPeersUpdate)
|
||||
err = runServerPeerUpdate(newnode.Network, shouldPeersUpdate, "node_grpc update")
|
||||
if err != nil {
|
||||
logger.Log(1, "could not update peers on gRPC after node,", newnode.ID, "updated (gRPC), \nerror:", err.Error())
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ func (s *NodeServiceServer) DeleteNode(ctx context.Context, req *nodepb.Object)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = runServerPeerUpdate(node.Network, false)
|
||||
err = runServerPeerUpdate(node.Network, false, "node_grpc delete")
|
||||
if err != nil {
|
||||
logger.Log(1, "internal error when setting peers after deleting node:", node.ID, "over gRPC")
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func createRelay(w http.ResponseWriter, r *http.Request) {
|
|||
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||
return
|
||||
}
|
||||
if err = runServerPeerUpdate(relay.NetID, isServer(&node)); err != nil {
|
||||
if err = runServerPeerUpdate(relay.NetID, isServer(&node), "relay create"); err != nil {
|
||||
logger.Log(1, "internal error when creating relay on node:", relay.NodeID)
|
||||
}
|
||||
go func() {
|
||||
|
@ -53,7 +53,7 @@ func deleteRelay(w http.ResponseWriter, r *http.Request) {
|
|||
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||
return
|
||||
}
|
||||
if err = runServerPeerUpdate(netid, isServer(&node)); err != nil {
|
||||
if err = runServerPeerUpdate(netid, isServer(&node), "relay delete"); err != nil {
|
||||
logger.Log(1, "internal error when deleting relay on node:", nodeid)
|
||||
}
|
||||
go func() {
|
||||
|
|
|
@ -6,7 +6,8 @@ import (
|
|||
"github.com/gravitl/netmaker/servercfg"
|
||||
)
|
||||
|
||||
func runServerPeerUpdate(network string, ifaceDelta bool) error {
|
||||
func runServerPeerUpdate(network string, ifaceDelta bool, function string) error {
|
||||
logger.Log(0, "running server update from function", function)
|
||||
err := logic.TimerCheckpoint()
|
||||
if err != nil {
|
||||
logger.Log(3, "error occurred on timer,", err.Error())
|
||||
|
|
|
@ -220,7 +220,6 @@ func setServerPeers(iface string, keepalive int32, peers []wgtypes.PeerConfig) e
|
|||
if err != nil {
|
||||
logger.Log(0, "error removing peer", peer.Endpoint.String())
|
||||
}
|
||||
logger.Log(0, "removed peer:", peer.Endpoint.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +248,7 @@ func setServerPeers(iface string, keepalive int32, peers []wgtypes.PeerConfig) e
|
|||
for _, peer := range peers {
|
||||
if len(peer.AllowedIPs) > 0 &&
|
||||
(peer.PublicKey.String() == currentPeer.PublicKey.String() ||
|
||||
peer.AllowedIPs[0].String() == currentPeer.PublicKey.String()) {
|
||||
peer.AllowedIPs[0].String() == currentPeer.AllowedIPs[0].String()) {
|
||||
shouldDelete = false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue