mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-08 22:24:17 +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 {
|
||||
return
|
||||
}
|
||||
if metrics == nil || metrics.Connectivity == nil {
|
||||
if metrics == nil || metrics.Connectivity == nil || len(metrics.Connectivity) == 0 {
|
||||
if time.Since(node.LastCheckIn) < models.LastCheckInThreshold {
|
||||
node.Status = models.OnlineSt
|
||||
return
|
||||
}
|
||||
if node.LastCheckIn.IsZero() {
|
||||
node.Status = models.OfflineSt
|
||||
return
|
||||
}
|
||||
}
|
||||
// if node.IsFailOver {
|
||||
// if time.Since(node.LastCheckIn) < models.LastCheckInThreshold {
|
||||
|
@ -133,9 +137,12 @@ func checkPeerStatus(node *models.Node, defaultAclPolicy bool) {
|
|||
if err != nil {
|
||||
continue
|
||||
}
|
||||
allowed, _ := logic.IsNodeAllowedToCommunicate(*node, peer, false)
|
||||
if !defaultAclPolicy && !allowed {
|
||||
continue
|
||||
|
||||
if !defaultAclPolicy {
|
||||
allowed, _ := logic.IsNodeAllowedToCommunicate(*node, peer, false)
|
||||
if !allowed {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if time.Since(peer.LastCheckIn) > models.LastCheckInThreshold {
|
||||
|
@ -154,7 +161,7 @@ func checkPeerStatus(node *models.Node, defaultAclPolicy bool) {
|
|||
node.Status = models.OnlineSt
|
||||
return
|
||||
}
|
||||
if peerNotConnectedCnt == len(metrics.Connectivity) {
|
||||
if len(metrics.Connectivity) > 0 && peerNotConnectedCnt == len(metrics.Connectivity) {
|
||||
node.Status = models.ErrorSt
|
||||
return
|
||||
}
|
||||
|
@ -195,7 +202,7 @@ func checkPeerConnectivity(node *models.Node, metrics *models.Metrics, defaultAc
|
|||
return
|
||||
}
|
||||
|
||||
if peerNotConnectedCnt == len(metrics.Connectivity) {
|
||||
if len(metrics.Connectivity) > 0 && peerNotConnectedCnt == len(metrics.Connectivity) {
|
||||
node.Status = models.ErrorSt
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue