forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
23 lines (21 loc) · 961 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package discovery
// This file contains helper filter methods to process the unfiltered list of
// tablets returned by HealthCheck.GetTabletStatsFrom*.
// See also replicationlag.go for a more sophisicated filter used by vtgate.
// RemoveUnhealthyTablets filters all unhealthy tablets out.
// NOTE: Non-serving tablets are considered healthy.
func RemoveUnhealthyTablets(tabletStatsList []TabletStats) []TabletStats {
result := make([]TabletStats, 0, len(tabletStatsList))
for _, ts := range tabletStatsList {
// Note we do not check the 'Serving' flag here.
// This is mainly to avoid the case where we run a vtworker Diff between a
// source and destination, and the source is not serving (disabled by
// TabletControl). When we switch the tablet to 'worker', it will
// go back to serving state.
if ts.Stats == nil || ts.Stats.HealthError != "" || IsReplicationLagHigh(&ts) {
continue
}
result = append(result, ts)
}
return result
}