Skip to content

Commit

Permalink
fix status for new added nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek9686 committed Jan 9, 2025
1 parent 323e03b commit 04f2dc2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pro/logic/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 04f2dc2

Please sign in to comment.