replace entire nodeStats object (#393)

This commit is contained in:
David Colburn
2022-01-31 17:09:36 -07:00
committed by GitHub
parent 745939ec24
commit 3d132730f9
6 changed files with 66 additions and 67 deletions
+5 -1
View File
@@ -462,9 +462,13 @@ func (r *RedisRouter) handleRTCMessage(rm *livekit.RTCNodeMessage) error {
break
}
if err := prometheus.UpdateCurrentNodeStats(r.currentNode.Stats); err != nil {
updated, err := prometheus.GetUpdatedNodeStats(r.currentNode.Stats)
if err != nil {
logger.Errorw("could not update node stats", err)
} else {
r.currentNode.Stats = updated
}
// TODO: check stats against config.Limit values
if err := r.RegisterNode(); err != nil {
logger.Errorw("could not update node", err)
+3 -2
View File
@@ -19,11 +19,12 @@ func (s *SystemLoadSelector) filterNodes(nodes []*livekit.Node) ([]*livekit.Node
nodesLowLoad := make([]*livekit.Node, 0)
for _, node := range nodes {
numCpus := node.Stats.NumCpus
stats := node.Stats
numCpus := stats.NumCpus
if numCpus == 0 {
numCpus = 1
}
if node.Stats.LoadAvgLast1Min/float32(numCpus) < s.SysloadLimit {
if stats.LoadAvgLast1Min/float32(numCpus) < s.SysloadLimit {
nodesLowLoad = append(nodesLowLoad, node)
}
}