-
Notifications
You must be signed in to change notification settings - Fork 855
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
Refactor apis.provisioning requirements #1155
Conversation
✔️ Deploy Preview for karpenter-docs-prod canceled. 🔨 Explore the source changes: 99d3eb0 🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/61fd8d9d6423290008b9a2d9 |
4354ddf
to
784072b
Compare
55b0178
to
28a7716
Compare
28a7716
to
d148db2
Compare
636be99
to
bb0356f
Compare
Interesting CI errors:
|
bb0356f
to
de69847
Compare
This is indeed a very interesting case caused by the init problem we discussed about. Turns out that when a constraints object is created without properly initializing the requirements, since requirements is not nil (no longer a pointer), it will not be ignored (tag ignoreempty no longer work). So when the constraints object is serialized, the requirements.Requirements is a nil. That's causing the problem. I managed to patch this by init the requirments.Requirments in the requriements MarshalJSON function. I am hesitate to call this a fix because it may happen if other functions are called. |
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.
LGTM! Worth getting some eyes from @bwagner5. I'd also like to hear about some manual testing. Can you do thorough manual testing against a real cluster and update the description.
Did a brunch of manual tests and it works fabulously. Please see the PR descriptions about the manual tests performed. |
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.
Nice work! Huge change! The only critical thing to address is the IgnoredLabels
since this will break the EBS in-tree driver.
} | ||
// The legal operators for pod affinity and anti-affinity are In, NotIn, Exists, DoesNotExist. |
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 comment is inaccurate. This is not pod affinity. This is node affinity. There is no node antiaffinity. I think you can get away with not having any comment at all.
// The legal operators for pod affinity and anti-affinity are In, NotIn, Exists, DoesNotExist. |
@@ -32,10 +31,10 @@ func (c *Constraints) defaultCapacityTypes() { | |||
if _, ok := c.Labels[v1alpha5.LabelCapacityType]; ok { | |||
return | |||
} | |||
if functional.ContainsString(c.Requirements.Keys(), v1alpha5.LabelCapacityType) { | |||
if c.Requirements.Keys().Has(v1alpha5.LabelCapacityType) { |
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.
Can we use c.Requirements.Get(v1alpha5.LabelCapacityType).Len()?
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.
lgtm! nice job!
Can't wait to try it! |
1. Issue, if available:
Karpenter relies on the provisioner API to calculate the requirements and constraints for pod scheduling and resource provisioning. The current implementation logic only handles specify use cases and causes wrong scheduling and resource estimation errors for general use cases (Noticeably issue #1084 that daemonSet pods are not considered during resource provisioning). This patch corrects the requirement logics and relaxes the inflexibility of the current design. It will enable the development of the following features.
Resolve #1084
2. Description of changes:
3. How was this change tested?
Included unit tests that test the new features.
Manually tested:
4. Does this change impact docs?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.