Skip to content

Commit

Permalink
chore: Fix undecided time naming (#1833)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Nov 21, 2024
1 parent a03600e commit d75c0b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions pkg/controllers/metrics/pod/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ var (
[]string{podName, podNamespace},
)
// Stage: alpha
PodProvisioningSchedulingUndecidedTimeSeconds = opmetrics.NewPrometheusGauge(
PodSchedulingUndecidedTimeSeconds = opmetrics.NewPrometheusGauge(
crmetrics.Registry,
prometheus.GaugeOpts{
Namespace: metrics.Namespace,
Subsystem: metrics.PodSubsystem,
Name: "provisioning_scheduling_undecided_time_seconds",
Name: "scheduling_undecided_time_seconds",
Help: "The time from when Karpenter has seen a pod without making a scheduling decision for the pod. Note: this calculated from a point in memory, not by the pod creation timestamp.",
},
[]string{podName, podNamespace},
Expand Down Expand Up @@ -229,7 +229,7 @@ func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reco
podName: req.Name,
podNamespace: req.Namespace,
})
PodProvisioningSchedulingUndecidedTimeSeconds.Delete(map[string]string{
PodSchedulingUndecidedTimeSeconds.Delete(map[string]string{
podName: req.Name,
podNamespace: req.Namespace,
})
Expand Down Expand Up @@ -261,15 +261,15 @@ func (c *Controller) recordPodSchedulingUndecidedMetric(pod *corev1.Pod) {
nn := client.ObjectKeyFromObject(pod)
// If we've made a decision on this pod, delete the metric idempotently and return
if decisionTime := c.cluster.PodSchedulingDecisionTime(nn); !decisionTime.IsZero() {
PodProvisioningSchedulingUndecidedTimeSeconds.Delete(map[string]string{
PodSchedulingUndecidedTimeSeconds.Delete(map[string]string{
podName: pod.Name,
podNamespace: pod.Namespace,
})
return
}
// If we haven't made a decision, get the time that we ACK'd the pod and emit the metric based on that
if podAckTime := c.cluster.PodAckTime(nn); !podAckTime.IsZero() {
PodProvisioningSchedulingUndecidedTimeSeconds.Set(time.Since(podAckTime).Seconds(), map[string]string{
PodSchedulingUndecidedTimeSeconds.Set(time.Since(podAckTime).Seconds(), map[string]string{
podName: pod.Name,
podNamespace: pod.Namespace,
})
Expand Down
12 changes: 6 additions & 6 deletions pkg/controllers/metrics/pod/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ var _ = Describe("Pod Metrics", func() {

ExpectReconcileSucceeded(ctx, podController, client.ObjectKeyFromObject(p))
fakeClock.Step(1 * time.Hour)
_, found := FindMetricWithLabelValues("karpenter_pods_provisioning_scheduling_undecided_time_seconds", map[string]string{
_, found := FindMetricWithLabelValues("karpenter_pods_scheduling_undecided_time_seconds", map[string]string{
"name": p.GetName(),
"namespace": p.GetNamespace(),
})
Expand All @@ -262,7 +262,7 @@ var _ = Describe("Pod Metrics", func() {
ExpectReconcileSucceeded(ctx, podController, client.ObjectKeyFromObject(p))
fakeClock.Step(1 * time.Hour)

_, found = FindMetricWithLabelValues("karpenter_pods_provisioning_scheduling_undecided_time_seconds", map[string]string{
_, found = FindMetricWithLabelValues("karpenter_pods_scheduling_undecided_time_seconds", map[string]string{
"name": p.GetName(),
"namespace": p.GetNamespace(),
})
Expand All @@ -271,7 +271,7 @@ var _ = Describe("Pod Metrics", func() {
cluster.MarkPodSchedulingDecisions(map[*corev1.Pod]error{}, p)
ExpectReconcileSucceeded(ctx, podController, client.ObjectKeyFromObject(p))

_, found = FindMetricWithLabelValues("karpenter_pods_provisioning_scheduling_undecided_time_seconds", map[string]string{
_, found = FindMetricWithLabelValues("karpenter_pods_scheduling_undecided_time_seconds", map[string]string{
"name": p.GetName(),
"namespace": p.GetNamespace(),
})
Expand All @@ -284,7 +284,7 @@ var _ = Describe("Pod Metrics", func() {

ExpectReconcileSucceeded(ctx, podController, client.ObjectKeyFromObject(p))
fakeClock.Step(1 * time.Hour)
_, found := FindMetricWithLabelValues("karpenter_pods_provisioning_scheduling_undecided_time_seconds", map[string]string{
_, found := FindMetricWithLabelValues("karpenter_pods_scheduling_undecided_time_seconds", map[string]string{
"name": p.GetName(),
"namespace": p.GetNamespace(),
})
Expand All @@ -295,7 +295,7 @@ var _ = Describe("Pod Metrics", func() {
ExpectReconcileSucceeded(ctx, podController, client.ObjectKeyFromObject(p))
fakeClock.Step(1 * time.Hour)

_, found = FindMetricWithLabelValues("karpenter_pods_provisioning_scheduling_undecided_time_seconds", map[string]string{
_, found = FindMetricWithLabelValues("karpenter_pods_scheduling_undecided_time_seconds", map[string]string{
"name": p.GetName(),
"namespace": p.GetNamespace(),
})
Expand All @@ -304,7 +304,7 @@ var _ = Describe("Pod Metrics", func() {
ExpectDeleted(ctx, env.Client, p)
ExpectReconcileSucceeded(ctx, podController, client.ObjectKeyFromObject(p))

_, found = FindMetricWithLabelValues("karpenter_pods_provisioning_scheduling_undecided_time_seconds", map[string]string{
_, found = FindMetricWithLabelValues("karpenter_pods_scheduling_undecided_time_seconds", map[string]string{
"name": p.GetName(),
"namespace": p.GetNamespace(),
})
Expand Down

0 comments on commit d75c0b7

Please sign in to comment.