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 maxUnavailable nodes calculation from percentages to only consider matching nodes #719

Merged
merged 1 commit into from
Mar 25, 2021

Conversation

rhrazdil
Copy link
Collaborator

Change how maxUnavailable node cound is computed from percentages
In the original commit that introduced maxUnavailable field, the number of nodes
that can run in parallel is computed from the entire cluster node count, when percentage
value is specified. This commit changes that to use only label matching nodes.

So if a nodeSelector is specified that selects half of cluster nodes, then specifying 50% maxUnavailable
will only allow half of the nodes that have the matching label to run in parallel.

Is this a BUG FIX or a FEATURE ?:

Uncomment only one, leave it on its own line:

/kind bug

/kind enhancement

What this PR does / why we need it:

Special notes for your reviewer:

Release note:

maxUnavailable node count is calculated from mathing nodes only when percentage is specified

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Mar 25, 2021
@rhrazdil
Copy link
Collaborator Author

/hold
waiting for #717 to land

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 25, 2021
@rhrazdil rhrazdil force-pushed the fix_matching_nodes_count branch 2 times, most recently from bebf389 to f2b73dd Compare March 25, 2021 07:18
Copy link
Member

@qinqon qinqon left a comment

Choose a reason for hiding this comment

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

Looks good, let's try to remove duplication and encapsulate things propertly.

if err != nil {
return 0, err
}
func (r *NodeNetworkConfigurationPolicyReconciler) maxUnavailableNodeCount(policy *nmstatev1beta1.NodeNetworkConfigurationPolicy, matchingNodes int) (int, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Remove the matchingNodes argument and call enactmentCount.Matching() inside at the end this is what we want to do, we don't need to parameterize it also remove the (r *NodeNetworkConfigurationPolicyReconciler) receiver since is not used, we can even move this undier ./pkg and make it public to use it at integratin tests.

@@ -37,7 +37,7 @@ const TestPolicy = "test-policy"
var (
bridgeCounter = 0
bondConunter = 0
maxUnavailable = environment.GetIntVarWithDefault("NMSTATE_MAX_UNAVAILABLE", 1)
maxUnavailable = environment.GetVarWithDefault("NMSTATE_MAX_UNAVAILABLE", "50%")
Copy link
Member

Choose a reason for hiding this comment

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

Let's make the default value public somewhere at pkg so we use it at tests too.

@@ -539,3 +539,15 @@ func skipIfNotKubernetes() {
Skip("Tutorials use interface naming that is available only on Kubernetes providers")
}
}

func maxUnavailableNodeCount() int {
Copy link
Member

Choose a reason for hiding this comment

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

As said let's try to use the same logic from porduct moving the function under pkg and usint it on tests.

@qinqon
Copy link
Member

qinqon commented Mar 25, 2021

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2021
@kubevirt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qinqon

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 25, 2021
Instead of calculating number of maxUnavailable nodes from
all nmstate enabled nodes, use matching nodes only.

Signed-off-by: Radim Hrazdil <[email protected]>
@rhrazdil rhrazdil force-pushed the fix_matching_nodes_count branch from 28be74c to b2f374b Compare March 25, 2021 10:58
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2021
@rhrazdil
Copy link
Collaborator Author

@qinqon sorry forgot to replace the 50% string in utils, fixed

@kubevirt-bot
Copy link
Collaborator

@rhrazdil: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-nmstate-e2e-handler-k8s-future b2f374b link /test pull-kubernetes-nmstate-e2e-handler-k8s-future

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. I understand the commands that are listed here.

@qinqon
Copy link
Member

qinqon commented Mar 25, 2021

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2021
@qinqon
Copy link
Member

qinqon commented Mar 25, 2021

/hold cancel

This no longer depends on the lanes aggregation.

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 25, 2021
@kubevirt-bot kubevirt-bot merged commit 73dab1f into nmstate:master Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/bug lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants