Skip to content

Commit

Permalink
metrics: update MCDDrainErr & remove cardinality
Browse files Browse the repository at this point in the history
- Refactor metric to correctly fire with new drain refactor.
- Remove unnecessary metric labels to simplify metrics & ensure
there is always only metric per node/mcd.
  • Loading branch information
kikisdeliveryservice committed Jun 4, 2021
1 parent 88cca46 commit dc6506e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/daemon/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (dn *Daemon) drain() error {
done <- true
failMsg := fmt.Sprintf("failed to drain node : %s after 1 hour", dn.node.Name)
dn.recorder.Eventf(getNodeRef(dn.node), corev1.EventTypeWarning, "FailedToDrain", failMsg)
MCDDrainErr.Set(1)
return errors.New(failMsg)
case <-drainer():
return nil
Expand All @@ -98,7 +99,6 @@ func (dn *Daemon) performDrain() error {
}

// We are here, that means we need to cordon and drain node
MCDDrainErr.WithLabelValues(dn.node.Name, "").Set(0)
dn.logSystem("Update prepared; beginning drain")
startTime := time.Now()

Expand All @@ -111,7 +111,7 @@ func (dn *Daemon) performDrain() error {
dn.logSystem("drain complete")
t := time.Since(startTime).Seconds()
glog.Infof("Successful drain took %v seconds", t)
MCDDrainErr.WithLabelValues(dn.node.Name, "").Set(0)
MCDDrainErr.Set(0)

return nil
}
9 changes: 5 additions & 4 deletions pkg/daemon/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ var (
Help: "indicates a successful SSH login",
})

// MCDDrainErr logs errors received during failed drain
MCDDrainErr = prometheus.NewGaugeVec(
// MCDDrainErr logs failed drain
MCDDrainErr = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "mcd_drain_err",
Help: "errors from failed drain",
}, []string{"node", "err"})
Help: "logs failed drain",
})

// MCDPivotErr shows errors encountered during pivot
MCDPivotErr = prometheus.NewGaugeVec(
Expand Down Expand Up @@ -88,6 +88,7 @@ func registerMCDMetrics() error {
}
}

MCDDrainErr.Set(0)
MCDPivotErr.WithLabelValues("", "", "").Set(0)
KubeletHealthState.Set(0)
MCDRebootErr.WithLabelValues("", "", "").Set(0)
Expand Down

0 comments on commit dc6506e

Please sign in to comment.