Merge pull request #75442 from mars1024/bugfix/bandwidth_unit

change bandwidth units from Kb to b
k3s-v1.15.3
Kubernetes Prow Robot 2019-04-25 13:36:54 -07:00 committed by GitHub
commit f4937619a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -398,11 +398,14 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string
if ingress != nil || egress != nil { if ingress != nil || egress != nil {
bandwidthParam := cniBandwidthEntry{} bandwidthParam := cniBandwidthEntry{}
if ingress != nil { if ingress != nil {
bandwidthParam.IngressRate = int(ingress.Value() / 1000) // see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md and
// https://github.com/containernetworking/plugins/blob/master/plugins/meta/bandwidth/README.md
// Rates are in bits per second, burst values are in bits.
bandwidthParam.IngressRate = int(ingress.Value())
bandwidthParam.IngressBurst = math.MaxInt32 // 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())
bandwidthParam.EgressBurst = math.MaxInt32 // no limit bandwidthParam.EgressBurst = math.MaxInt32 // no limit
} }
rt.CapabilityArgs["bandwidth"] = bandwidthParam rt.CapabilityArgs["bandwidth"] = bandwidthParam

View File

@ -291,7 +291,7 @@ func TestCNIPlugin(t *testing.T) {
t.Errorf("mismatch in expected port mappings. expected %v got %v", expectedMappings, inputConfig.RuntimeConfig.PortMappings) t.Errorf("mismatch in expected port mappings. expected %v got %v", expectedMappings, inputConfig.RuntimeConfig.PortMappings)
} }
expectedBandwidth := map[string]interface{}{ expectedBandwidth := map[string]interface{}{
"ingressRate": 1000.0, "egressRate": 1000.0, "ingressRate": 1000000.0, "egressRate": 1000000.0,
"ingressBurst": 2147483647.0, "egressBurst": 2147483647.0, "ingressBurst": 2147483647.0, "egressBurst": 2147483647.0,
} }
if !reflect.DeepEqual(inputConfig.RuntimeConfig.Bandwidth, expectedBandwidth) { if !reflect.DeepEqual(inputConfig.RuntimeConfig.Bandwidth, expectedBandwidth) {