@@ -26,10 +26,6 @@ func getNodeStatusOld(node *models.Node) {
26
26
27
27
func GetNodeStatus (node * models.Node , defaultEnabledPolicy bool ) {
28
28
29
- if time .Since (node .LastCheckIn ) > models .LastCheckInThreshold {
30
- node .Status = models .OfflineSt
31
- return
32
- }
33
29
if node .IsStatic {
34
30
if ! node .StaticNode .Enabled {
35
31
node .Status = models .OfflineSt
@@ -53,6 +49,10 @@ func GetNodeStatus(node *models.Node, defaultEnabledPolicy bool) {
53
49
node .Status = models .UnKnown
54
50
return
55
51
}
52
+ if time .Since (node .LastCheckIn ) > models .LastCheckInThreshold {
53
+ node .Status = models .OfflineSt
54
+ return
55
+ }
56
56
host , err := logic .GetHost (node .HostID .String ())
57
57
if err != nil {
58
58
node .Status = models .UnKnown
@@ -168,9 +168,12 @@ func checkPeerConnectivity(node *models.Node, metrics *models.Metrics, defaultAc
168
168
if err != nil {
169
169
continue
170
170
}
171
- allowed , _ := logic .IsNodeAllowedToCommunicate (* node , peer , false )
172
- if ! defaultAclPolicy && ! allowed {
173
- continue
171
+
172
+ if ! defaultAclPolicy {
173
+ allowed , _ := logic .IsNodeAllowedToCommunicate (* node , peer , false )
174
+ if ! allowed {
175
+ continue
176
+ }
174
177
}
175
178
176
179
if time .Since (peer .LastCheckIn ) > models .LastCheckInThreshold {
@@ -181,19 +184,22 @@ func checkPeerConnectivity(node *models.Node, metrics *models.Metrics, defaultAc
181
184
}
182
185
// check if peer is in error state
183
186
checkPeerStatus (& peer , defaultAclPolicy )
184
- if peer .Status == models .ErrorSt {
187
+ if peer .Status == models .ErrorSt || peer . Status == models . WarningSt {
185
188
continue
186
189
}
187
190
peerNotConnectedCnt ++
188
191
189
192
}
190
- if peerNotConnectedCnt == 0 {
191
- node .Status = models .OnlineSt
193
+ if peerNotConnectedCnt > len ( metrics . Connectivity ) / 2 {
194
+ node .Status = models .WarningSt
192
195
return
193
196
}
197
+
194
198
if peerNotConnectedCnt == len (metrics .Connectivity ) {
195
199
node .Status = models .ErrorSt
196
200
return
197
201
}
198
- node .Status = models .WarningSt
202
+
203
+ node .Status = models .OnlineSt
204
+
199
205
}
0 commit comments