Skip to content

Commit

Permalink
Update evaluator metrics to reflect actual state every cycle
Browse files Browse the repository at this point in the history
It was only updating the metrics on new evaluation cycle, meaning that
if autoscaler was restarted mid cycle - it would cause loss of signal.
  • Loading branch information
dee-kryvenko committed Feb 14, 2025
1 parent 57aa286 commit 6b93435
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,29 +300,29 @@ func (r *MostWantedTwoPhaseHysteresisEvaluationReconciler) Reconcile(ctx context
evaluation.Status.LastEvaluationTimestamp = ptr.To(metav1.Now())
log.Info("New partitioning has won",
"replicas", len(evaluation.Status.Replicas), "lastEvaluationTimestamp", evaluation.Status.LastEvaluationTimestamp)
mostWantedTwoPhaseHysteresisEvaluationShardsGauge.DeletePartialMatch(prometheus.Labels{
"evaluation_ref": req.NamespacedName.String(),
})
mostWantedTwoPhaseHysteresisEvaluationReplicasTotalLoadGauge.DeletePartialMatch(prometheus.Labels{
"evaluation_ref": req.NamespacedName.String(),
})
for _, replica := range topSeenRecord.Replicas {
for _, li := range replica.LoadIndexes {
mostWantedTwoPhaseHysteresisEvaluationShardsGauge.WithLabelValues(
req.NamespacedName.String(),
string(li.Shard.UID),
li.Shard.ID,
li.Shard.Namespace,
li.Shard.Name,
li.Shard.Server,
strconv.Itoa(int(replica.ID)),
).Set(1)
}
mostWantedTwoPhaseHysteresisEvaluationReplicasTotalLoadGauge.WithLabelValues(
}
mostWantedTwoPhaseHysteresisEvaluationShardsGauge.DeletePartialMatch(prometheus.Labels{
"evaluation_ref": req.NamespacedName.String(),
})
mostWantedTwoPhaseHysteresisEvaluationReplicasTotalLoadGauge.DeletePartialMatch(prometheus.Labels{
"evaluation_ref": req.NamespacedName.String(),
})
for _, replica := range evaluation.Status.Replicas {
for _, li := range replica.LoadIndexes {
mostWantedTwoPhaseHysteresisEvaluationShardsGauge.WithLabelValues(
req.NamespacedName.String(),
string(li.Shard.UID),
li.Shard.ID,
li.Shard.Namespace,
li.Shard.Name,
li.Shard.Server,
strconv.Itoa(int(replica.ID)),
).Set(replica.TotalLoad.AsApproximateFloat64())
).Set(1)
}
mostWantedTwoPhaseHysteresisEvaluationReplicasTotalLoadGauge.WithLabelValues(
req.NamespacedName.String(),
strconv.Itoa(int(replica.ID)),
).Set(replica.TotalLoad.AsApproximateFloat64())
}

meta.SetStatusCondition(&evaluation.Status.Conditions, metav1.Condition{
Expand Down

0 comments on commit 6b93435

Please sign in to comment.