mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-13 13:14:11 +08:00
fix network sync
This commit is contained in:
parent
35884056b3
commit
6bbe817e4b
1 changed files with 18 additions and 7 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/gravitl/netmaker/logic"
|
"github.com/gravitl/netmaker/logic"
|
||||||
"github.com/gravitl/netmaker/models"
|
"github.com/gravitl/netmaker/models"
|
||||||
"github.com/gravitl/netmaker/servercfg"
|
"github.com/gravitl/netmaker/servercfg"
|
||||||
|
"github.com/gravitl/netmaker/serverctl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeServiceServer - represents the service server for gRPC
|
// NodeServiceServer - represents the service server for gRPC
|
||||||
|
@ -144,15 +145,25 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.Object)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServerAddrs(node *models.Node) {
|
func getServerAddrs(node *models.Node) {
|
||||||
serverNode := logic.GetServerNodes(node.Network)[0]
|
serverNodes := logic.GetServerNodes(node.Network)
|
||||||
//pubIP, _ := servercfg.GetPublicIP()
|
//pubIP, _ := servercfg.GetPublicIP()
|
||||||
var serverAddrs = []models.ServerAddr{
|
if len(serverNodes) == 0 {
|
||||||
{
|
if err := serverctl.SyncServerNetwork(node); err != nil {
|
||||||
IsLeader: true,
|
return
|
||||||
Address: serverNode.Address,
|
}
|
||||||
ID: serverNode.ID,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var serverAddrs = make([]models.ServerAddr, 1)
|
||||||
|
|
||||||
|
for _, node := range serverNodes {
|
||||||
|
|
||||||
|
serverAddrs = append(serverAddrs, models.ServerAddr{
|
||||||
|
IsLeader: logic.IsLeader(&node),
|
||||||
|
Address: node.Address,
|
||||||
|
ID: node.ID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
networkSettings, _ := logic.GetParentNetwork(node.Network)
|
networkSettings, _ := logic.GetParentNetwork(node.Network)
|
||||||
// TODO consolidate functionality around files
|
// TODO consolidate functionality around files
|
||||||
networkSettings.NodesLastModified = time.Now().Unix()
|
networkSettings.NodesLastModified = time.Now().Unix()
|
||||||
|
|
Loading…
Reference in a new issue