-
Notifications
You must be signed in to change notification settings - Fork 545
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
Add support for Subscription.config.affinity #2826
Add support for Subscription.config.affinity #2826
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: perdasilva The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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 split the o-f/api bump from the code changes here?
5180132
to
66f009d
Compare
For no one but you, @timflannagan |
// special case: if overriding affinity is empty/default, | ||
// nil out the deployment affinity | ||
if reflect.DeepEqual(&corev1.Affinity{}, affinity) { | ||
podSpec.Affinity = nil |
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.
Should we bother overwriting the affinity in this case? I just wonder if we're going to encounter more conflict type errors needlessly? We could just return early here.
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.
That's basically the semantic of the empty/default override. I.e.
Subscription looking like
config:
affinity: {}
should end up as a pod spec w/o affinity. I guess the alternative would be to have something like:
affinity: {}
in the podSpec. But that felt kinda dangly to me. wdyt?
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 also think this should be safe. As affinity: {}
-> corev1.Affinity{} - right?
newAffinityValue := reflect.ValueOf(affinity) | ||
curAffinityValue := reflect.ValueOf(podSpec.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.
Do we need to use ValueOf
if these types are not interfaces? Couldn't we just dereference them normally?
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 point of this code was to handle API changes dynamically. I've updated to remove most of the reflection stuff and make it more readable/maintainable. I've added a unit test to detect whether there are been API changes and fail CI with a helpful message of what to do.
10ef362
to
ded5083
Compare
Signed-off-by: perdasilva <perdasilva@redhat.com>
Signed-off-by: perdasilva <perdasilva@redhat.com>
ded5083
to
2fbe53e
Compare
/lgtm |
Signed-off-by: perdasilva perdasilva@redhat.com
Description of the change:
Adds possibility to override operator deployment pod affinity.
Pulls in latest commit of api as pseudo-version. Will update to api version once this is good. Subscription.config now contains affinity. To override values:
or
I used reflections to automatically capture any affinity changes in the API coming from upstream kube
Motivation for the change:
Help schedule operators in multiarch environments
Architectural changes:
N/A
Testing remarks:
Not adding e2e since that would really just test the kube scheduler. Opted for more aggressive unit testing to ensure the spec is modified properly. I've also done some manual testing against a kind cluster with two nodes, manipulating namespace labels and including dummy pods to test out the node, pod, and pod anti- affinity settings. Seems to work.
Reviewer Checklist
/doc
[FLAKE]
are truly flaky and have an issue