Skip to content

Commit f493761

Browse files
authored
Merge pull request kubernetes#75442 from mars1024/bugfix/bandwidth_unit
change bandwidth units from Kb to b
2 parents ed2ab71 + 183247c commit f493761

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pkg/kubelet/dockershim/network/cni/cni.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,14 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string
398398
if ingress != nil || egress != nil {
399399
bandwidthParam := cniBandwidthEntry{}
400400
if ingress != nil {
401-
bandwidthParam.IngressRate = int(ingress.Value() / 1000)
401+
// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md and
402+
// https://github.com/containernetworking/plugins/blob/master/plugins/meta/bandwidth/README.md
403+
// Rates are in bits per second, burst values are in bits.
404+
bandwidthParam.IngressRate = int(ingress.Value())
402405
bandwidthParam.IngressBurst = math.MaxInt32 // no limit
403406
}
404407
if egress != nil {
405-
bandwidthParam.EgressRate = int(egress.Value() / 1000)
408+
bandwidthParam.EgressRate = int(egress.Value())
406409
bandwidthParam.EgressBurst = math.MaxInt32 // no limit
407410
}
408411
rt.CapabilityArgs["bandwidth"] = bandwidthParam

pkg/kubelet/dockershim/network/cni/cni_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func TestCNIPlugin(t *testing.T) {
291291
t.Errorf("mismatch in expected port mappings. expected %v got %v", expectedMappings, inputConfig.RuntimeConfig.PortMappings)
292292
}
293293
expectedBandwidth := map[string]interface{}{
294-
"ingressRate": 1000.0, "egressRate": 1000.0,
294+
"ingressRate": 1000000.0, "egressRate": 1000000.0,
295295
"ingressBurst": 2147483647.0, "egressBurst": 2147483647.0,
296296
}
297297
if !reflect.DeepEqual(inputConfig.RuntimeConfig.Bandwidth, expectedBandwidth) {

0 commit comments

Comments
 (0)