From 30139f71125004325a008570fcfee0879f0d82ae Mon Sep 17 00:00:00 2001 From: xiaofeiwang Date: Tue, 5 Jun 2018 14:47:07 +0800 Subject: [PATCH 1/2] Modified that check burst value when run the function ValidateNetprofile 1. The burst is hard code, if want to achieve the desired performance, it's best to equal the value of bandwidth. 2. Add func ConvertBandwidth,that convert the bandwidth to bytes. 3. Modified func ValidateNetprofile. 4. Test pass on local env --- contivmodel/contivModel.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contivmodel/contivModel.go b/contivmodel/contivModel.go index 99e2dbd84..ebd2c41c2 100644 --- a/contivmodel/contivModel.go +++ b/contivmodel/contivModel.go @@ -9,6 +9,7 @@ import ( "errors" log "github.com/Sirupsen/logrus" "github.com/contiv/netplugin/objdb/modeldb" + "github.com/contiv/netplugin/utils/netutils" "github.com/gorilla/mux" "net/http" "regexp" @@ -3457,7 +3458,8 @@ func ValidateNetprofile(obj *Netprofile) error { return errors.New("bandwidth string invalid format") } - if obj.Burst > 10486 { + bwint64 := netutils.ConvertBandwidth(obj.Bandwidth) + if int64(obj.Burst) > bwint64 { return errors.New("burst Value Out of bound") } From 781dde53b3a61a3af4affcba718cd0fa3187da54 Mon Sep 17 00:00:00 2001 From: xiaofeiwang Date: Tue, 5 Jun 2018 15:27:35 +0800 Subject: [PATCH 2/2] Remove speaces for check burst value --- contivmodel/contivModel.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contivmodel/contivModel.go b/contivmodel/contivModel.go index ebd2c41c2..319aee681 100644 --- a/contivmodel/contivModel.go +++ b/contivmodel/contivModel.go @@ -9,7 +9,7 @@ import ( "errors" log "github.com/Sirupsen/logrus" "github.com/contiv/netplugin/objdb/modeldb" - "github.com/contiv/netplugin/utils/netutils" + "github.com/contiv/netplugin/utils/netutils" "github.com/gorilla/mux" "net/http" "regexp" @@ -3458,8 +3458,8 @@ func ValidateNetprofile(obj *Netprofile) error { return errors.New("bandwidth string invalid format") } - bwint64 := netutils.ConvertBandwidth(obj.Bandwidth) - if int64(obj.Burst) > bwint64 { + bwint64 := netutils.ConvertBandwidth(obj.Bandwidth) + if int64(obj.Burst) > bwint64 { return errors.New("burst Value Out of bound") }