-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(ksm): set ksm-enabled label to true independently from node pressure #11306
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
Conversation
Skipping CI for Draft Pull Request. |
/cc @jean-edouard |
protected might be misleading. Specifically because ksm has a security to it. |
1166f3b
to
0e229c0
Compare
Thanks @fabiand! Looks much better! Adjusted PR description and commit message as well! |
/cc |
pkg/virt-handler/heartbeat/ksm.go
Outdated
@@ -249,32 +249,33 @@ func getIntParam(node *v1.Node, param string, defaultValue, lowerBound, upperBou | |||
// will set the outcome value to the n.KSM struct | |||
// If the node labels match the selector terms, the ksm will be enabled. | |||
// Empty Selector will enable ksm for every node | |||
func handleKSM(node *v1.Node, clusterConfig *virtconfig.ClusterConfig) (bool, bool) { | |||
available, running := loadKSM() | |||
func handleKSM(node *v1.Node, clusterConfig *virtconfig.ClusterConfig) (ksmHandlerEnabled, ksmEnabledByUs bool) { |
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 think that a better name would be shouldSetKsmAsEnabled
i was confused by the these names
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 know that this part is not trivial at all, but IMHO this function will not just enable KSM, but disable it too.
I will leave the rename discussion for a separate/refactoring PR. WDYT? Thanks
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 was speaking about the return value ksmHandlerEnabled
personally the name really confused me maybe we can fnid a better name than shouldSetKsmAsEnabled
But IIUC this var only point is to set the value of this label
so maybe something like ksmLabelValue
would make more sense?
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.
Got you! I like the ksmLabelValue
.
Don't we need to remove or change line 151 in ksm.go to
or maybe change line 187 in
To make the changes in this PR description? |
0e229c0
to
df1a875
Compare
@Barakmor1 Thanks for the review! I pushed almost all the changes with the suggested code. PTAL |
This PR is just to change the node labelling behavior, not the ksm activation logic. |
If this is the case why do we need this PR? Maybe we should change the name of this label i find it super confusing... Maybe something like |
df1a875
to
70c41f5
Compare
Because we need to provide users the information that a particular node is configured to use ksm, so that it can be used to schedule vms there. |
I think that the name of the label is very confusing and we should avoid setting label called |
70c41f5
to
383c8e6
Compare
pkg/virt-handler/heartbeat/ksm.go
Outdated
if ksmConfig == nil && enabled { | ||
disableKSM(node) | ||
return false, false | ||
} | ||
|
||
selector, err := metav1.LabelSelectorAsSelector(ksmConfig.NodeLabelSelector) | ||
if err != nil { | ||
log.DefaultLogger().Errorf("An error occurred while converting the ksm selector: %s", err) | ||
return running, false | ||
return false, false | ||
} | ||
|
||
if !selector.Matches(labels.Set(node.ObjectMeta.Labels)) { | ||
if disableKSM(node, running) { | ||
return false, false | ||
} else { | ||
return running, false | ||
} | ||
if !selector.Matches(labels.Set(node.ObjectMeta.Labels)) && enabled { | ||
disableKSM(node) | ||
return false, false |
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 do we need the && enabled
?
I think that we should return from this func even if it is not enabled
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.
You are right, but we also don't want to write always the same value, when ksm is disabled.
Will adjust! Thank you
383c8e6
to
21ad5ae
Compare
Neither IMO. We need to restore KSM behavior to what's documented in user-guide, which this PR does, thank you! :) |
Sounds good to me, maybe we can think of something in a follow up PR |
/lgtm @fossedihelm Thank you |
Thank you both @jean-edouard @Barakmor1 |
Currently, KubeVirt adds the `kubevirt.io/ksm-enabled` label to those nodes that match the labelSelector defined in kvConfiguration. The value of that label will be true only if that node is under pressure, false otherwise. This is wrong since we need to provide users the information that a particular node is configured to use ksm, so that it can be used to schedule vms there. Signed-off-by: fossedihelm <ffossemo@redhat.com>
21ad5ae
to
cc674ee
Compare
@Barakmor1 Changes rebase |
/lgtm |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jean-edouard 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 |
Required labels detected, running phase 2 presubmits: |
/retest-required |
1 similar comment
/retest-required |
/cherrypick release-1.2 |
@fossedihelm: once the present PR merges, I will cherry-pick it on top of release-1.2 in a new PR and assign it to you. In response to this:
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/test-infra repository. |
/retest-required |
/retest |
@fossedihelm: #11306 failed to apply on top of branch "release-1.2":
In response to this:
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/test-infra repository. |
What this PR does
Before this PR:
Currently, KubeVirt adds the
kubevirt.io/ksm-enabled
label to those nodes that match the labelSelector defined in kvConfiguration. The value of that label will be true only if that node is under pressure, false otherwise.After this PR:
This is wrong since we need to provide users the information that a particular node is configured to use ksm, so that it can be used to schedule vms there.
Fixes #
jira-ticket: https://issues.redhat.com/browse/CNV-38568
Why we need it and why it was done in this way
The following tradeoffs were made:
The following alternatives were considered:
Links to places where the discussion took place:
Special notes for your reviewer
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Design: A design document was considered and is present (link) or not requiredUpgrade: Impact of this change on upgrade flows was considered and addressed if requiredDocumentation: A user-guide update was considered and is present (link) or not required. You want a user-guide update if it's a user facing feature / API change.Community: Announcement to kubevirt-dev was consideredRelease note