Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding traffic shaping support for CNI network driver #63194

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

m1093782566
Copy link
Contributor

@m1093782566 m1093782566 commented Apr 26, 2018

What this PR does / why we need it:

Adding traffic shaping support for CNI network driver - it's also a sub-task of kubenet deprecation work.

Design document is available here: kubernetes/community#1893

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

/cc @freehan @jingax10 @caseydavenport @dcbw

/sig network
/sig node

Release note:

Support traffic shaping for CNI network driver

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 26, 2018
@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Apr 26, 2018
@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 26, 2018
@m1093782566
Copy link
Contributor Author

/assign @thockin

@thockin
Copy link
Member

thockin commented May 14, 2018

This looks OK, but I'll need someone to really try it out. What can we do about testing?

@m1093782566
Copy link
Contributor Author

I'll need someone to really try it out. What can we do about testing?

My team member @Lion-Wei is working on adding some e2e test cases for this feature.

@m1093782566
Copy link
Contributor Author

/assign @rramkumar1

Can you take a look when you have chance? :)

Thanks!

@dcbw
Copy link
Member

dcbw commented May 23, 2018

/lgtm though as noted we should really have some tests too

@@ -68,6 +69,21 @@ type cniPortMapping struct {
HostIP string `json:"hostIP"`
}

// cniBandwidthEntry maps to the standard CNI bandwidth Capability
// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Lion-Wei
Copy link

@dcbw ,I think we better have some e2e test case about bandwidth, but cni plugin v0.8 have not been released yet, so how to get bandwidth package in our test, that'a a problem. : (

@m1093782566
Copy link
Contributor Author

m1093782566 commented May 24, 2018

As @Lion-Wei mentioned, my team has been working on adding e2e tests for some days but we find

  • There is no specific job for running CNI-plugins-related test cases. We need to create new test job in kubernetes/test-infra.

  • If we reuse the test jobs kubeadm-gce-cni-calico and kubeadm-gce-cni-flannel, we should add their --ginkgo.focus like [Feature: Bandwidth]. We need to update the test job in kubernetes/test-infra as well.

So, can we let this PR in first and then update the jobs in kubernetes/test-infra? My team will continue to work on it.

BTW, the functionalities of cni bandwidth plugins is already being tested in containernetworking/plugins repo, so can we just write some UTs in kubernetes repo for now?

@m1093782566
Copy link
Contributor Author

@thockin @dcbw

I just added some tests, PTAL.

// cniBandwidthEntry maps to the standard CNI bandwidth Capability
// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md
type cniBandwidthEntry struct {
// IngressRate is the bandwidth rate in Kbps for traffic through container. 0 for no limit. If ingressRate is set, ingressBurst must also be set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug in the CNI documentation; it is actually bits per second.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

bandwidthParam := cniBandwidthEntry{}
if ingress != nil {
bandwidthParam.IngressRate = int(ingress.Value() / 1000)
bandwidthParam.IngressBurst = int(ingress.Value() / 1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value should be hard-coded to 1600 bits - it's the linux TC default and is what kubenet uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks!

if ingress != nil || egress != nil {
bandwidthParam := cniBandwidthEntry{}
if ingress != nil {
bandwidthParam.IngressRate = int(ingress.Value() / 1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation was wrong; the units are bits per second.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks!

bandwidthParam.IngressBurst = int(ingress.Value() / 1000)
}
if egress != nil {
bandwidthParam.EgressRate = int(egress.Value() / 1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bits per second here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
if egress != nil {
bandwidthParam.EgressRate = int(egress.Value() / 1000)
bandwidthParam.EgressBurst = int(egress.Value() / 1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be the default of 1600

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md
type cniBandwidthEntry struct {
// IngressRate is the bandwidth rate in Kbps for traffic through container. 0 for no limit. If ingressRate is set, ingressBurst must also be set
IngressRate int `json:"ingressRate"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these fields should have omitEmpty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@squeed
Copy link
Contributor

squeed commented May 30, 2018

I did a manual end-to-end test as part of #64445 and found some bugs - left some comments.

@m1093782566
Copy link
Contributor Author

m1093782566 commented May 31, 2018

@squeed

Thanks for your comments, we have addressed all of them. PTAL.

BTW, I find there are some bandwidth-related changes in #64445 as well. As my friend(@Lion-Wei) and I started this work 2 months ago and have spent lots of time doing it, can we let this PR in first and then rework #64445?

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jul 8, 2018
@Lion-Wei
Copy link

Lion-Wei commented Jul 9, 2018

/lgtm
/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 9, 2018
@m1093782566
Copy link
Contributor Author

Thanks @Lion-Wei

/hold

for @thockin final review :)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 9, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 9, 2018
@m1093782566
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 9, 2018
@timchenxiaoyu
Copy link
Contributor

does support change bandwith dynamic when pods in runtime ?

@m1093782566
Copy link
Contributor Author

m1093782566 commented Jul 9, 2018

@timchenxiaoyu

does support change bandwith dynamic when pods in runtime?

Currently, it doesn't support - we configure bandwidth limit in pod start up. I think we can support it if we get better consensus.

@thockin
Copy link
Member

thockin commented Jul 9, 2018

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 9, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dcbw, Lion-Wei, m1093782566, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@m1093782566
Copy link
Contributor Author

THANKS @thockin

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet