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

add concurrency limiter to ovs-vsctl #3288

Merged
merged 2 commits into from
Oct 11, 2023
Merged

Conversation

qiutingjun
Copy link
Contributor

@qiutingjun qiutingjun commented Oct 8, 2023

What type of this PR

Examples of user facing changes:

  • Features

Features
add rate limiter to limit the number of concurrent executions of the ovs-vsctl command

Which issue(s) this PR fixes:
Fixes #3210

WHAT

🤖 Generated by Copilot at 5a35e40

This pull request adds a new feature to limit the concurrency of ovs-vsctl commands, which are used by the kube-ovn daemon to configure Open vSwitch on each node. It also fixes a bug in the ovsClientRequestLatency metric and adds tests for the new feature. The feature can be configured through a command-line argument, a helm value, or a yaml file, depending on the deployment mode. The default concurrency limit is 100.

🤖 Generated by Copilot at 5a35e40

ovs-vsctl calls
Limited by concurrency
Winter of OVS

HOW

🤖 Generated by Copilot at 5a35e40

  • Add concurrency limit logic for ovs-vsctl commands (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Define and initialize a global Limiter variable in the ovs-vsctl.go file to control the number of concurrent ovs-vsctl commands (link)
  • Add a new argument named ovs-vsctl-concurrency to the ovn-cni container in the ovncni-ds.yaml, kube-ovn-dual-stack.yaml, and kube-ovn-ipv6.yaml files to specify the concurrency limit (link, link, link)
  • Add a new value named ovsVsctlConcurrency to the helm chart values file to define the default concurrency limit of 100 (link)
  • Add a new field named OVSVsctlConcurrency to the Configuration type in the config.go file to store the concurrency limit value (link)
  • Parse the ovs-vsctl-concurrency argument from the command-line and assign it to the OVSVsctlConcurrency field of the config object in the config.go file (link, link)
  • Import the ovs package in the cniserver.go file and call the UpdateOVSVsctlLimiter function with the OVSVsctlConcurrency value from the config object to update the limit field of the Limiter variable (link, link)
  • Modify the Exec function in the ovs-vsctl.go file to use the Limiter variable and the context package to wait until the limiter allows the execution of the ovs-vsctl command or the context is canceled by timeout, and to increment and decrement the current field of the Limiter variable (link, link)
  • Fix a bug that causes the code variable to always be "0" in the defer statement of the Exec function by assigning it before the defer statement (link)
  • Import the context, sync/atomic, and time packages in the util.go file to use the context type, atomic operations, and timeouts in the Limiter type and its methods (link)
  • Define the Limiter type and its methods in the util.go file to implement the concurrency limit logic (link)
  • Add test cases for the Limiter type and its methods in the util_test.go file (link, link)
    • Import the context and time packages in the util_test.go file to create contexts with timeouts and timers for testing the Limiter type and its methods (link)
    • Add the Test_Limiter test case and its subtests to test the Limiter type and its methods with different scenarios, such as without limit, with limit, and with timeout (link)

@bobz965 bobz965 merged commit b6192f3 into kubeovn:master Oct 11, 2023
58 checks passed
bobz965 pushed a commit that referenced this pull request Oct 11, 2023
* add concurrency limiter to ovs-vsctl

* allow unlimited concurrency



---------

Signed-off-by: 夜微澜 <[email protected]>
@qiutingjun qiutingjun deleted the rate branch October 13, 2023 01:13
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.

kube-ovn-cni needs to limit the number of concurrent executions of the ovs-vsctl command
3 participants