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 bug with pod node affinity testing #1550

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

tzneal
Copy link
Contributor

@tzneal tzneal commented Mar 20, 2022

1. Issue, if available:
N/A

2. Description of changes:

Adds a test and fixes a bug related to not checking pod node affinity.

3. How was this change tested?
Unit test + on EKS

4. Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: link to issue
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@netlify
Copy link

netlify bot commented Mar 20, 2022

✅ Deploy Preview for karpenter-docs-prod canceled.

🔨 Explore the source changes: 79d31a5

🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/6237cc842bd3c10008b0cfa0

@tzneal tzneal force-pushed the refactor-and-fix-node-affinity-bug branch from 32c4b9d to c5b8096 Compare March 20, 2022 18:53
@tzneal tzneal force-pushed the refactor-and-fix-node-affinity-bug branch from c5b8096 to c04fd70 Compare March 21, 2022 00:36
@@ -80,14 +58,14 @@ func (n Node) Compatible(pod *v1.Pod) error {
return err
}

tightened := n.Constraints.Requirements.Add(podRequirements.Requirements...)
Copy link
Contributor

@ellistarn ellistarn Mar 21, 2022

Choose a reason for hiding this comment

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

This feels like we're tripping over ourselves a bit. This is a tight loop that scales linearly with pods. We're already adding these requirements together inside n.Constraints.Requirements.Compatible(podRequirements), and then we're doing it again here. Effectively, we have two areas of the code base responsible for the same thing (e.g. checking if a pod can schedule to a node), but done at different levels of abstraction.

As you've rightly done, we don't want to push this logic into the API package to create a dependency between v1alpha5 -> cloudprovider. Instead, if we could move the compatibility logic up to this layer, I think a lot of this impedance mismatch goes away. Obviously, we're blocked on this right now due to #1549, but it might be worth exploring once that's merged.

I'm happy to merge this PR as it is currently, but would love to remove this rough edge for simplicity/performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was debating if the initial compatibility check was required when I wrote this and ended up with the conclusion that I wasn't certain that our Add() was written to handle possibly incompatible requirements, so it felt safer to keep it in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just verified that the outer compatibility check handles the stuff that's not instance related (e.g. hostname requirements to implement topology spread).

Copy link
Contributor

Choose a reason for hiding this comment

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

Not currently. You'd need to smoosh em together :D

@tzneal tzneal force-pushed the refactor-and-fix-node-affinity-bug branch from c04fd70 to 79d31a5 Compare March 21, 2022 00:53
@tzneal tzneal merged commit 14d84eb into aws:main Mar 21, 2022
@tzneal tzneal deleted the refactor-and-fix-node-affinity-bug branch March 21, 2022 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants