Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET-1894: check peer status #3283

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions pro/logic/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ func getNodeStatusOld(node *models.Node) {

func GetNodeStatus(node *models.Node, defaultEnabledPolicy bool) {

if time.Since(node.LastCheckIn) > models.LastCheckInThreshold {
node.Status = models.OfflineSt
return
}
if node.IsStatic {
if !node.StaticNode.Enabled {
node.Status = models.OfflineSt
Expand All @@ -53,6 +49,10 @@ func GetNodeStatus(node *models.Node, defaultEnabledPolicy bool) {
node.Status = models.UnKnown
return
}
if time.Since(node.LastCheckIn) > models.LastCheckInThreshold {
node.Status = models.OfflineSt
return
}
host, err := logic.GetHost(node.HostID.String())
if err != nil {
node.Status = models.UnKnown
Expand Down Expand Up @@ -168,9 +168,12 @@ func checkPeerConnectivity(node *models.Node, metrics *models.Metrics, defaultAc
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 @@ -181,19 +184,22 @@ func checkPeerConnectivity(node *models.Node, metrics *models.Metrics, defaultAc
}
// check if peer is in error state
checkPeerStatus(&peer, defaultAclPolicy)
if peer.Status == models.ErrorSt {
if peer.Status == models.ErrorSt || peer.Status == models.WarningSt {
continue
}
peerNotConnectedCnt++

}
if peerNotConnectedCnt == 0 {
node.Status = models.OnlineSt
if peerNotConnectedCnt > len(metrics.Connectivity)/2 {
node.Status = models.WarningSt
return
}

if peerNotConnectedCnt == len(metrics.Connectivity) {
node.Status = models.ErrorSt
return
}
node.Status = models.WarningSt

node.Status = models.OnlineSt

}
15 changes: 15 additions & 0 deletions servercfg/serverconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,21 @@ func GetMqUserName() string {
return password
}

// GetMetricInterval - get the publish metric interval
func GetMetricIntervalInMinutes() time.Duration {
//default 15 minutes
mi := "15"
if os.Getenv("PUBLISH_METRIC_INTERVAL") != "" {
mi = os.Getenv("PUBLISH_METRIC_INTERVAL")
}
interval, err := strconv.Atoi(mi)
if err != nil {
interval = 15
}

return time.Duration(interval) * time.Minute
}

// GetMetricInterval - get the publish metric interval
func GetMetricInterval() string {
//default 15 minutes
Expand Down
Loading