-
Notifications
You must be signed in to change notification settings - Fork 289
fix: make sure nodeclaims hostname are also set #2156
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
base: main
Are you sure you want to change the base?
Conversation
Welcome @rajpopat27! |
Hi @rajpopat27. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/assign @jonathan-innis |
// ignore the node if it doesn't match the topology group | ||
if !tg.nodeFilter.Matches(n.Node.Spec.Taints, scheduling.NewLabelRequirements(n.Node.Labels)) { | ||
if !tg.nodeFilter.Matches(n.Taints(), scheduling.NewLabelRequirements(n.Labels())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n.Labels() doesn't have hostname hydrated into it if it still hasn't resolved to a Node -- we should consider injecting hostname into the labels, which would make this code work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathan-innis The nodeclaim get that kubernetes.io/hostname labels once it is launched
created, err := l.cloudProvider.Create(ctx, nodeClaim) |
nodeClaim = PopulateNodeClaimDetails(nodeClaim, created) |
And the only the nodeclaim that are launched will appear in state nodes
karpenter/pkg/controllers/state/cluster.go
Line 138 in fc274d1
if providerID == "" { |
and in the countDomains we are only checking nodes that are in state nodes so I guess should be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hostname does not get propagated on launch -- for instance, on AWS, this change doesn't work because we don't see the hostname until the node actually joins the cluster so the same bug is present.
I'm suspecting you might be running into this because our KWOK cloudprovider doesn't model this quite right today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see okay let me make the changes for this
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rajpopat27 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Pull Request Test Coverage Report for Build 15017125737Details
💛 - Coveralls |
|
||
// We special-case kubernetes.io/hostname primarily for stateNodes having NodeClaims without a node | ||
// and since their domain won't be registered until the node joins the cluster. | ||
if !exists && tg.Key == corev1.LabelHostname { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused why we need to fake the value in this code here -- why don't we just fake the value at the StateNode and then we don't have to special-case code in this scheduling section. I think all this fix amounts to is passing the same value that n.HostName() has back through n.Labels(). Seems like that would simplify a lot of this and you wouldn't have to make any changes to this section of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the NodeClaim name, which is used as the hostname in topologies, is a generated value created after the p.Create method provisions the NodeClaim using kubeClient.
Would you recommend issuing a patch request to update the NodeClaim's labels by setting the hostname label to match the NodeClaim name? If not, could you suggest a more appropriate stage or mechanism for assigning the hostname label based on the NodeClaim name?
An alternative approach I considered is to incorporate this logic into the c.UpdateNodeClaim method—specifically, to check whether the NodeClaim lacks a hostname label and has an empty hostname value, and if so, to assign the hostname label accordingly.
@@ -306,6 +306,39 @@ func ExpectProvisioned(ctx context.Context, c client.Client, cluster *state.Clus | |||
return bindings | |||
} | |||
|
|||
//nolint:gocyclo | |||
func ExpectProvisionedNoNode(ctx context.Context, c client.Client, cluster *state.Cluster, cloudProvider cloudprovider.CloudProvider, provisioner *provisioning.Provisioner, pods ...*corev1.Pod) ([]*v1.NodeClaim, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Why return an error here when you can just enforce the lack of errors through expectations?
//nolint:gocyclo | ||
func ExpectProvisionedNoNode(ctx context.Context, c client.Client, cluster *state.Cluster, cloudProvider cloudprovider.CloudProvider, provisioner *provisioning.Provisioner, pods ...*corev1.Pod) ([]*v1.NodeClaim, error) { | ||
GinkgoHelper() | ||
nodeClaims := []*v1.NodeClaim{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodeClaims := []*v1.NodeClaim{} | |
var nodeClaims []*v1.NodeClaim |
nit: style
@@ -306,6 +306,39 @@ func ExpectProvisioned(ctx context.Context, c client.Client, cluster *state.Clus | |||
return bindings | |||
} | |||
|
|||
//nolint:gocyclo | |||
func ExpectProvisionedNoNode(ctx context.Context, c client.Client, cluster *state.Cluster, cloudProvider cloudprovider.CloudProvider, provisioner *provisioning.Provisioner, pods ...*corev1.Pod) ([]*v1.NodeClaim, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function is a subset of the other function, can you just use this function in ExepctProvisionedNoBinding()?
@@ -175,6 +175,13 @@ func (c *CloudProvider) Create(ctx context.Context, nodeClaim *v1.NodeClaim) (*v | |||
labels[req.Key] = req.Any() | |||
} | |||
|
|||
// add the derived nodeclaim requirement labels as we do in addInstanceLabels in KWOK provider | |||
for _, r := range nodeClaim.Spec.Requirements { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why specifically do you need this in your change if your change has to do with hostname specifically?
Fixes #2123
Description
Make sure karpenter considers nodeclaims while counting Domains
How was this change tested?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.