add concurrency limiter to ovs-vsctl #3288
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of this PR
Examples of user facing changes:
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 theovsClientRequestLatency
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
HOW
🤖 Generated by Copilot at 5a35e40
ovs-vsctl.go
file to control the number of concurrent ovs-vsctl commands (link)ovs-vsctl-concurrency
to the ovn-cni container in theovncni-ds.yaml
,kube-ovn-dual-stack.yaml
, andkube-ovn-ipv6.yaml
files to specify the concurrency limit (link, link, link)ovsVsctlConcurrency
to the helm chart values file to define the default concurrency limit of 100 (link)OVSVsctlConcurrency
to the Configuration type in theconfig.go
file to store the concurrency limit value (link)ovs-vsctl-concurrency
argument from the command-line and assign it to theOVSVsctlConcurrency
field of the config object in theconfig.go
file (link, link)cniserver.go
file and call theUpdateOVSVsctlLimiter
function with theOVSVsctlConcurrency
value from the config object to update the limit field of the Limiter variable (link, link)Exec
function in theovs-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)Exec
function by assigning it before the defer statement (link)util.go
file to use the context type, atomic operations, and timeouts in the Limiter type and its methods (link)util.go
file to implement the concurrency limit logic (link)util_test.go
file (link, link)util_test.go
file to create contexts with timeouts and timers for testing the Limiter type and its methods (link)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)