From b573cce5953266805bcba40731e395e3cdc17657 Mon Sep 17 00:00:00 2001 From: Yongkun Gui Date: Tue, 23 Oct 2018 15:39:43 -0700 Subject: [PATCH] cni: rate and limit must be both set Fix #70014 --- pkg/kubelet/dockershim/network/cni/cni.go | 5 +++-- pkg/kubelet/dockershim/network/cni/cni_test.go | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/dockershim/network/cni/cni.go b/pkg/kubelet/dockershim/network/cni/cni.go index c8fbdbb315f..f177a3ed80d 100644 --- a/pkg/kubelet/dockershim/network/cni/cni.go +++ b/pkg/kubelet/dockershim/network/cni/cni.go @@ -19,6 +19,7 @@ package cni import ( "errors" "fmt" + "math" "sort" "strings" "sync" @@ -377,11 +378,11 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string bandwidthParam := cniBandwidthEntry{} if ingress != nil { bandwidthParam.IngressRate = int(ingress.Value() / 1000) - bandwidthParam.IngressBurst = 0 // default to no limit + bandwidthParam.IngressBurst = math.MaxInt32 // no limit } if egress != nil { bandwidthParam.EgressRate = int(egress.Value() / 1000) - bandwidthParam.EgressBurst = 0 // default to no limit + bandwidthParam.EgressBurst = math.MaxInt32 // no limit } rt.CapabilityArgs["bandwidth"] = bandwidthParam } diff --git a/pkg/kubelet/dockershim/network/cni/cni_test.go b/pkg/kubelet/dockershim/network/cni/cni_test.go index 5d83d991e3b..152fa0b161f 100644 --- a/pkg/kubelet/dockershim/network/cni/cni_test.go +++ b/pkg/kubelet/dockershim/network/cni/cni_test.go @@ -291,6 +291,7 @@ func TestCNIPlugin(t *testing.T) { } expectedBandwidth := map[string]interface{}{ "ingressRate": 1000.0, "egressRate": 1000.0, + "ingressBurst": 2147483647.0, "egressBurst": 2147483647.0, } if !reflect.DeepEqual(inputConfig.RuntimeConfig.Bandwidth, expectedBandwidth) { t.Errorf("mismatch in expected bandwidth. expected %v got %v", expectedBandwidth, inputConfig.RuntimeConfig.Bandwidth)