-
Notifications
You must be signed in to change notification settings - Fork 288
fix: Ensure DaemonSets with '/initialized' and '/registered' are considered during nodeclaim calculations #2161
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,12 @@ func NewNodeClaimTemplate(nodePool *v1.NodePool) *NodeClaimTemplate { | |
}) | ||
nct.Requirements.Add(scheduling.NewNodeSelectorRequirementsWithMinValues(nct.Spec.Requirements...).Values()...) | ||
nct.Requirements.Add(scheduling.NewLabelRequirements(nct.Labels).Values()...) | ||
|
||
// Add requirements for DaemonSet scheduling calculations | ||
// These ensure DaemonSets with nodeAffinity for these labels are considered | ||
nct.Requirements.Add(scheduling.NewRequirement(v1.NodeRegisteredLabelKey, corev1.NodeSelectorOpIn, "true")) | ||
nct.Requirements.Add(scheduling.NewRequirement(v1.NodeInitializedLabelKey, corev1.NodeSelectorOpIn, "true")) | ||
|
||
return nct | ||
} | ||
|
||
|
@@ -80,6 +86,14 @@ func (i *NodeClaimTemplate) ToNodeClaim() *v1.NodeClaim { | |
return i.Name | ||
})...)) | ||
|
||
// Filter out DaemonSet scheduling-only requirements for the actual NodeClaim | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: These may not just be DaemonSet scheduling requirements -- I'm not sure why you would do this on things other than DaemonSets, but we should technically support this for any pod that selected against this label There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jonathan-innis Apologies for the delay.
Addressing this would require logic to prevent excessive NodeClaim creation when Pending Pods exist with registered/initialized labels. |
||
requirements := scheduling.NewRequirements() | ||
for key, req := range i.Requirements { | ||
if key != v1.NodeRegisteredLabelKey && key != v1.NodeInitializedLabelKey { | ||
requirements.Add(req) | ||
} | ||
} | ||
|
||
nc := &v1.NodeClaim{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
GenerateName: fmt.Sprintf("%s-", i.NodePoolName), | ||
|
@@ -97,7 +111,7 @@ func (i *NodeClaimTemplate) ToNodeClaim() *v1.NodeClaim { | |
}, | ||
Spec: i.Spec, | ||
} | ||
nc.Spec.Requirements = i.Requirements.NodeSelectorRequirements() | ||
nc.Spec.Requirements = requirements.NodeSelectorRequirements() | ||
if nc.Spec.TerminationGracePeriod == nil { | ||
nc.Spec.TerminationGracePeriod = DefaultTerminationGracePeriod | ||
} | ||
|
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.
This looks good! Can we add one test to make sure that this works properly on the two new labels? Maybe something with affinity?
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 have implemented a test that verifies nodes are launched with properly calculated daemonOverhead and scheduled correctly when NodeAffinity is configured for each respective label.