mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Merge pull request #70149 from anfernee/fix-70014
cni: rate and limit must be both set
This commit is contained in:
commit
610bcbb55e
@ -19,6 +19,7 @@ package cni
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -377,11 +378,11 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string
|
|||||||
bandwidthParam := cniBandwidthEntry{}
|
bandwidthParam := cniBandwidthEntry{}
|
||||||
if ingress != nil {
|
if ingress != nil {
|
||||||
bandwidthParam.IngressRate = int(ingress.Value() / 1000)
|
bandwidthParam.IngressRate = int(ingress.Value() / 1000)
|
||||||
bandwidthParam.IngressBurst = 0 // default to no limit
|
bandwidthParam.IngressBurst = math.MaxInt32 // no limit
|
||||||
}
|
}
|
||||||
if egress != nil {
|
if egress != nil {
|
||||||
bandwidthParam.EgressRate = int(egress.Value() / 1000)
|
bandwidthParam.EgressRate = int(egress.Value() / 1000)
|
||||||
bandwidthParam.EgressBurst = 0 // default to no limit
|
bandwidthParam.EgressBurst = math.MaxInt32 // no limit
|
||||||
}
|
}
|
||||||
rt.CapabilityArgs["bandwidth"] = bandwidthParam
|
rt.CapabilityArgs["bandwidth"] = bandwidthParam
|
||||||
}
|
}
|
||||||
|
@ -291,6 +291,7 @@ func TestCNIPlugin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
expectedBandwidth := map[string]interface{}{
|
expectedBandwidth := map[string]interface{}{
|
||||||
"ingressRate": 1000.0, "egressRate": 1000.0,
|
"ingressRate": 1000.0, "egressRate": 1000.0,
|
||||||
|
"ingressBurst": 2147483647.0, "egressBurst": 2147483647.0,
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(inputConfig.RuntimeConfig.Bandwidth, expectedBandwidth) {
|
if !reflect.DeepEqual(inputConfig.RuntimeConfig.Bandwidth, expectedBandwidth) {
|
||||||
t.Errorf("mismatch in expected bandwidth. expected %v got %v", expectedBandwidth, inputConfig.RuntimeConfig.Bandwidth)
|
t.Errorf("mismatch in expected bandwidth. expected %v got %v", expectedBandwidth, inputConfig.RuntimeConfig.Bandwidth)
|
||||||
|
Loading…
Reference in New Issue
Block a user