Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add capacity-type label to karpenter_nodeclaims_registered and karpen… #1211

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/controllers/node/termination/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func (c *Controller) removeFinalizer(ctx context.Context, n *v1.Node) error {
return client.IgnoreNotFound(fmt.Errorf("patching node, %w", err))
}
metrics.NodesTerminatedCounter.With(prometheus.Labels{
metrics.NodePoolLabel: n.Labels[v1beta1.NodePoolLabelKey],
metrics.NodePoolLabel: n.Labels[v1beta1.NodePoolLabelKey],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only added it for NodesTermianted for completeness, if we add it to NodesCreated

metrics.CapacityTypeLabel: n.Labels[v1beta1.CapacityTypeLabelKey],
}).Inc()
// We use stored.DeletionTimestamp since the api-server may give back a node after the patch without a deletionTimestamp
TerminationSummary.With(prometheus.Labels{
Expand Down
6 changes: 4 additions & 2 deletions pkg/controllers/nodeclaim/lifecycle/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ func (r *Registration) Reconcile(ctx context.Context, nodeClaim *v1beta1.NodeCla
nodeClaim.Status.NodeName = node.Name

metrics.NodeClaimsRegisteredCounter.With(prometheus.Labels{
metrics.NodePoolLabel: nodeClaim.Labels[v1beta1.NodePoolLabelKey],
metrics.NodePoolLabel: nodeClaim.Labels[v1beta1.NodePoolLabelKey],
metrics.CapacityTypeLabel: nodeClaim.Labels[v1beta1.CapacityTypeLabelKey],
}).Inc()
metrics.NodesCreatedCounter.With(prometheus.Labels{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might just need Nodeclaims or Node to have the capacity type. I can remove NodesCreated, I am not aware of the use case of adding both here in the first place, please advice

metrics.NodePoolLabel: nodeClaim.Labels[v1beta1.NodePoolLabelKey],
metrics.NodePoolLabel: nodeClaim.Labels[v1beta1.NodePoolLabelKey],
metrics.CapacityTypeLabel: nodeClaim.Labels[v1beta1.CapacityTypeLabelKey],
}).Inc()
return reconcile.Result{}, nil
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/controllers/provisioning/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@ func (p *Provisioner) Create(ctx context.Context, n *scheduler.NodeClaim, opts .
})
logging.FromContext(ctx).With("nodeclaim", nodeClaim.Name, "requests", nodeClaim.Spec.Resources.Requests, "instance-types", instanceTypeList(instanceTypeRequirement.Values)).Infof("created nodeclaim")
metrics.NodeClaimsCreatedCounter.With(prometheus.Labels{
metrics.ReasonLabel: options.Reason,
metrics.NodePoolLabel: nodeClaim.Labels[v1beta1.NodePoolLabelKey],
metrics.CapacityTypeLabel: nodeClaim.Labels[v1beta1.CapacityTypeLabelKey],
metrics.ReasonLabel: options.Reason,
metrics.NodePoolLabel: nodeClaim.Labels[v1beta1.NodePoolLabelKey],
}).Inc()
// Update the nodeclaim manually in state to avoid evenutal consistency delay races with our watcher.
// This is essential to avoiding races where disruption can create a replacement node, then immediately
Expand Down
3 changes: 2 additions & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var (
[]string{
ReasonLabel,
NodePoolLabel,
CapacityTypeLabel,
},
)
NodeClaimsTerminatedCounter = prometheus.NewCounterVec(
Expand Down Expand Up @@ -73,6 +72,7 @@ var (
},
[]string{
NodePoolLabel,
CapacityTypeLabel,
},
)
NodeClaimsInitializedCounter = prometheus.NewCounterVec(
Expand Down Expand Up @@ -119,6 +119,7 @@ var (
},
[]string{
NodePoolLabel,
CapacityTypeLabel,
},
)
NodesTerminatedCounter = prometheus.NewCounterVec(
Expand Down