Skip to content

Commit

Permalink
comment ACL call and add debug message
Browse files Browse the repository at this point in the history
  • Loading branch information
yabinma committed Nov 12, 2024
1 parent 276998b commit 767d1b5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
27 changes: 14 additions & 13 deletions logic/acls/nodeacls/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ var NodesAllowedACLMutex = &sync.Mutex{}

// AreNodesAllowed - checks if nodes are allowed to communicate in their network ACL
func AreNodesAllowed(networkID NetworkID, node1, node2 NodeID) bool {
NodesAllowedACLMutex.Lock()
defer NodesAllowedACLMutex.Unlock()
var currentNetworkACL, err = FetchAllACLs(networkID)
if err != nil {
return false
}
var allowed bool
acls.AclMutex.Lock()
currNetworkACLNode1 := currentNetworkACL[acls.AclID(node1)]
currNetworkACLNode2 := currentNetworkACL[acls.AclID(node2)]
acls.AclMutex.Unlock()
allowed = currNetworkACLNode1.IsAllowed(acls.AclID(node2)) && currNetworkACLNode2.IsAllowed(acls.AclID(node1))
return allowed
return true
// NodesAllowedACLMutex.Lock()
// defer NodesAllowedACLMutex.Unlock()
// var currentNetworkACL, err = FetchAllACLs(networkID)
// if err != nil {
// return false
// }
// var allowed bool
// acls.AclMutex.Lock()
// currNetworkACLNode1 := currentNetworkACL[acls.AclID(node1)]
// currNetworkACLNode2 := currentNetworkACL[acls.AclID(node2)]
// acls.AclMutex.Unlock()
// allowed = currNetworkACLNode1.IsAllowed(acls.AclID(node2)) && currNetworkACLNode2.IsAllowed(acls.AclID(node1))
// return allowed
}

// FetchNodeACL - fetches a specific node's ACL in a given network
Expand Down
24 changes: 22 additions & 2 deletions mq/publishers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"encoding/json"
"errors"
"fmt"
"runtime"
"sync"
"time"

"github.com/google/uuid"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
Expand All @@ -19,6 +21,15 @@ var batchUpdate = servercfg.GetBatchPeerUpdate()

// PublishPeerUpdate --- determines and publishes a peer update to all the hosts
func PublishPeerUpdate(replacePeers bool) error {
slog.Error("entering PublishPeerUpdate", "Debug")
pc, file, no, ok := runtime.Caller(1)
if ok {
slog.Error("called from ", file, no)
}
details := runtime.FuncForPC(pc)
if ok && details != nil {
slog.Error("called from ", details.Name())
}
if !servercfg.IsMessageQueueBackend() {
return nil
}
Expand All @@ -43,7 +54,11 @@ func PublishPeerUpdate(replacePeers bool) error {
host := host
go func(host models.Host) {
if err = PublishSingleHostPeerUpdate(&host, allNodes, nil, nil, replacePeers, nil); err != nil {
logger.Log(1, "failed to publish peer update to host", host.ID.String(), ": ", err.Error())
id := host.Name
if host.ID != uuid.Nil {
id = host.ID.String()
}
slog.Error("failed to publish peer update to host", id, ": ", err)
}
}(host)
}
Expand All @@ -60,12 +75,17 @@ func PublishPeerUpdate(replacePeers bool) error {
host := hosts[i]
go func(host models.Host) {
if err = PublishSingleHostPeerUpdate(&host, allNodes, nil, nil, replacePeers, &wg); err != nil {
logger.Log(1, "failed to publish peer update to host", host.ID.String(), ": ", err.Error())
id := host.Name
if host.ID != uuid.Nil {
id = host.ID.String()
}
slog.Error("failed to publish peer update to host", id, ": ", err)
}
}(host)
}
wg.Wait()
}
slog.Error("leaving PublishPeerUpdate", "Debug")
return nil
}

Expand Down

0 comments on commit 767d1b5

Please sign in to comment.