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

traffic shaping: take configuration via a runtimeConfig #138

Merged
merged 2 commits into from
Apr 25, 2018

Conversation

m1093782566
Copy link

To make it easier to supply bandwidth in a dynamic manner, the traffic shaping plugin should support a capability arg.

Fixes: #133

@m1093782566
Copy link
Author

m1093782566 commented Apr 3, 2018

@m1093782566
Copy link
Author

• Failure [0.796 seconds]
Basic PTP using cnitool when the bandwidth plugin is chained with a plugin that returns multiple adapters [Measurement] limits traffic only on the restricted bandwith veth device 
/home/travis/gopath/src/github.com/containernetworking/plugins/gopath/src/github.com/containernetworking/plugins/integration/integration_linux_test.go:151
  Expected
      <time.Duration>: 26698362
  to be >
      <time.Duration>: 1023954067
  /home/travis/gopath/src/github.com/containernetworking/plugins/gopath/src/github.com/containernetworking/plugins/integration/integration_linux_test.go:188

The failed test seems flaky, so how to re-trigger the test?

@dcbw
Copy link
Member

dcbw commented Apr 5, 2018

@m1093782566 restarted...

@dcbw
Copy link
Member

dcbw commented Apr 5, 2018

@m1093782566 I think it's useful to have both runtime config and static config; also allows limiting if the runtime doesn't yet support the dynamic modes. Other than that, looks OK... Maybe if the static config is specified, it overrides runtime config?

@Lion-Wei
Copy link

@dcbw By static config you mean config like this?

{
            "type": "bandwidth",
            "ingressRate": 800,
            "ingressBurst": 200,
            "egressRate": 800,
            "egressBurst": 200
}

@m1093782566
Copy link
Author

@dcbw CI is green now.

@dcbw
Copy link
Member

dcbw commented Apr 11, 2018

@Lion-Wei yeah, like that.

@squeed
Copy link
Member

squeed commented Apr 11, 2018

I agree with @dcbw - the plugin should take both static and runtime configuration

@Lion-Wei
Copy link

@dcbw @squeed , make sense. We can do that. : )

return types.PrintResult(conf.PrevResult, conf.CNIVersion)
bandwidth = conf.RuntimeConfig.BandWidth
//no traffic shaping was requested, so just no-op and quit
if bandwidth == nil || (bandwidth.IngressRate == 0 && bandwidth.IngressBurst == 0 && bandwidth.EgressRate == 0 && bandwidth.EgressBurst == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest you add an IsZero method on the BandwidthEntry type - makes these comparisons simpler.

Copy link
Member

Choose a reason for hiding this comment

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

Also, if you make the nested BandwidthEntry struct in config a pointer, this can be simpler.


RawPrevResult *map[string]interface{} `json:"prevResult"`
PrevResult *current.Result `json:"-"`
BandWidthEntry
Copy link
Member

Choose a reason for hiding this comment

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

The nested struct can be a pointer, and the json deserializer will handle it correctly - makes it easy to track empty values.

Copy link
Member

Choose a reason for hiding this comment

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

We do something similar with the host-local IPAM, if you want to see it in action.

Choose a reason for hiding this comment

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

Good Point, thanks, Now wit's can be much simpler, PTAL. : )

@squeed
Copy link
Member

squeed commented Apr 12, 2018

Minor request: The "w" in "bandwidth" should be lowercase everywhere, including config.

@squeed
Copy link
Member

squeed commented Apr 12, 2018

A few minor things, but otherwise looks good! When you're all done, can you squash to a single commit (and force-push to your branch)?

@m1093782566
Copy link
Author

m1093782566 commented Apr 13, 2018

@squeed I squashed the commits and it still have two commits: one is mine and the other one is my friend @Lion-Wei 's as I paired with him on this work :)

@m1093782566
Copy link
Author

@squeed @dcbw

All comments are addressed now. PTAL. BTW, the work of having Kubernetes CNI network driver support traffic shaping still relies on this PR.

@squeed
Copy link
Member

squeed commented Apr 18, 2018

Looks good to me. Is there any reason you changed the bandwidth values in the integration test? Nice job, btw.

@m1093782566
Copy link
Author

@squeed

Oops... It is changed back now. Please take a look again when you have a chance, thanks!

@squeed
Copy link
Member

squeed commented Apr 20, 2018

LGTM! Thanks! Now just need a second reviewer.

@m1093782566
Copy link
Author

Thanks @squeed

@dcbw would you please take a look?

@squeed squeed merged commit adba9ec into containernetworking:master Apr 25, 2018
@rosenhouse
Copy link
Contributor

back ref: kubernetes/kubernetes#63194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants