mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-13 00:24:31 +08:00
fix status for new added nodes
This commit is contained in:
parent
323e03b91b
commit
04f2dc2d6a
1 changed files with 13 additions and 6 deletions
|
@ -71,11 +71,15 @@ func GetNodeStatus(node *models.Node, defaultEnabledPolicy bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if metrics == nil || metrics.Connectivity == nil {
|
if metrics == nil || metrics.Connectivity == nil || len(metrics.Connectivity) == 0 {
|
||||||
if time.Since(node.LastCheckIn) < models.LastCheckInThreshold {
|
if time.Since(node.LastCheckIn) < models.LastCheckInThreshold {
|
||||||
node.Status = models.OnlineSt
|
node.Status = models.OnlineSt
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if node.LastCheckIn.IsZero() {
|
||||||
|
node.Status = models.OfflineSt
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if node.IsFailOver {
|
// if node.IsFailOver {
|
||||||
// if time.Since(node.LastCheckIn) < models.LastCheckInThreshold {
|
// if time.Since(node.LastCheckIn) < models.LastCheckInThreshold {
|
||||||
|
@ -133,9 +137,12 @@ func checkPeerStatus(node *models.Node, defaultAclPolicy bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
allowed, _ := logic.IsNodeAllowedToCommunicate(*node, peer, false)
|
|
||||||
if !defaultAclPolicy && !allowed {
|
if !defaultAclPolicy {
|
||||||
continue
|
allowed, _ := logic.IsNodeAllowedToCommunicate(*node, peer, false)
|
||||||
|
if !allowed {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if time.Since(peer.LastCheckIn) > models.LastCheckInThreshold {
|
if time.Since(peer.LastCheckIn) > models.LastCheckInThreshold {
|
||||||
|
@ -154,7 +161,7 @@ func checkPeerStatus(node *models.Node, defaultAclPolicy bool) {
|
||||||
node.Status = models.OnlineSt
|
node.Status = models.OnlineSt
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if peerNotConnectedCnt == len(metrics.Connectivity) {
|
if len(metrics.Connectivity) > 0 && peerNotConnectedCnt == len(metrics.Connectivity) {
|
||||||
node.Status = models.ErrorSt
|
node.Status = models.ErrorSt
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -195,7 +202,7 @@ func checkPeerConnectivity(node *models.Node, metrics *models.Metrics, defaultAc
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if peerNotConnectedCnt == len(metrics.Connectivity) {
|
if len(metrics.Connectivity) > 0 && peerNotConnectedCnt == len(metrics.Connectivity) {
|
||||||
node.Status = models.ErrorSt
|
node.Status = models.ErrorSt
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue