Merge pull request #70149 from anfernee/fix-70014

cni: rate and limit must be both set
This commit is contained in:
k8s-ci-robot 2018-11-01 22:16:26 -07:00 committed by GitHub
commit 610bcbb55e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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
} }

View File

@ -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)