mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-03 02:53:29 +08:00
added wipe failover cases and ceased node update on metrics update
This commit is contained in:
@@ -92,3 +92,30 @@ func WipeFailover(nodeid string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WipeAffectedFailoversOnly - wipes failovers for nodes that have given node (ID)
|
||||
// in their respective failover lists
|
||||
func WipeAffectedFailoversOnly(nodeid, network string) error {
|
||||
currentNetworkNodes, err := logic.GetNetworkNodes(network)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := range currentNetworkNodes {
|
||||
currNodeID := currentNetworkNodes[i].ID
|
||||
if currNodeID == nodeid {
|
||||
WipeFailover(nodeid)
|
||||
continue
|
||||
}
|
||||
currMetrics, err := logic.GetMetrics(currNodeID)
|
||||
if err != nil || currMetrics == nil {
|
||||
continue
|
||||
}
|
||||
if currMetrics.FailoverPeers != nil {
|
||||
if len(currMetrics.FailoverPeers[nodeid]) > 0 {
|
||||
WipeFailover(currNodeID)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user