From 52f582a02facc29d1984137451f230f9c5a95682 Mon Sep 17 00:00:00 2001 From: jgonzalez Date: Thu, 11 Apr 2019 13:03:59 +1000 Subject: [PATCH] Emit 0 cpu/mem for scale up from 0 --- pkg/controller/controller.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 78f0da74..f200f8e3 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -302,8 +302,15 @@ func (c *Controller) scaleNodeGroup(nodegroup string, nodeGroup *NodeGroupState) // Metrics log.WithField("nodegroup", nodegroup).Infof("cpu: %v, memory: %v", cpuPercent, memPercent) - metrics.NodeGroupsCPUPercent.WithLabelValues(nodegroup).Set(cpuPercent) - metrics.NodeGroupsMemPercent.WithLabelValues(nodegroup).Set(memPercent) + + // on the case that we're scaling up from 0, emit 0 as the metrics to keep metrics sane + if cpuPercent == math.MaxFloat64 || memPercent == math.MaxFloat64 { + metrics.NodeGroupsCPUPercent.WithLabelValues(nodegroup).Set(0) + metrics.NodeGroupsMemPercent.WithLabelValues(nodegroup).Set(0) + } else { + metrics.NodeGroupsCPUPercent.WithLabelValues(nodegroup).Set(cpuPercent) + metrics.NodeGroupsMemPercent.WithLabelValues(nodegroup).Set(memPercent) + } locked := nodeGroup.scaleUpLock.locked() if locked {