Skip to content

Commit

Permalink
Lock the hostmap before copying things from it during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brad-defined committed Mar 22, 2023
1 parent b18d715 commit df3e307
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions e2e/router/hostmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ func renderHostmap(c *nebula.Control) (string, []*edge) {

// Draw the vpn to index nodes
r += fmt.Sprintf("\t\tsubgraph %s.hosts[\"Hosts (vpn ip to index)\"]\n", clusterName)
for _, vpnIp := range sortedHosts(hm.Hosts) {
hm.RLock()
hosts := sortedHosts(hm.Hosts)
hm.RUnlock()
for _, vpnIp := range hosts {
hi := hm.Hosts[vpnIp]
r += fmt.Sprintf("\t\t\t%v.%v[\"%v\"]\n", clusterName, vpnIp, vpnIp)
lines = append(lines, fmt.Sprintf("%v.%v --> %v.%v", clusterName, vpnIp, clusterName, hi.GetLocalIndex()))
Expand Down Expand Up @@ -94,7 +97,10 @@ func renderHostmap(c *nebula.Control) (string, []*edge) {

// Draw the local index to relay or remote index nodes
r += fmt.Sprintf("\t\tsubgraph indexes.%s[\"Indexes (index to hostinfo)\"]\n", clusterName)
for _, idx := range sortedIndexes(hm.Indexes) {
hm.RLock()
indexes := sortedIndexes(hm.Indexes)
hm.RUnlock()
for _, idx := range indexes {
hi, ok := hm.Indexes[idx]
if ok {
r += fmt.Sprintf("\t\t\t%v.%v[\"%v (%v)\"]\n", clusterName, idx, idx, hi.GetVpnIp())
Expand Down

0 comments on commit df3e307

Please sign in to comment.