-
Notifications
You must be signed in to change notification settings - Fork 770
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
traffic shaping: take configuration via a runtimeConfig #138
Conversation
a279897
to
c0bb90b
Compare
The failed test seems flaky, so how to re-trigger the test? |
c0bb90b
to
c2df509
Compare
@m1093782566 restarted... |
@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? |
@dcbw By static config you mean config like this? {
"type": "bandwidth",
"ingressRate": 800,
"ingressBurst": 200,
"egressRate": 800,
"egressBurst": 200
} |
@dcbw CI is green now. |
@Lion-Wei yeah, like that. |
I agree with @dcbw - the plugin should take both static and runtime configuration |
plugins/meta/bandwidth/main.go
Outdated
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
plugins/meta/bandwidth/main.go
Outdated
|
||
RawPrevResult *map[string]interface{} `json:"prevResult"` | ||
PrevResult *current.Result `json:"-"` | ||
BandWidthEntry |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. : )
Minor request: The "w" in "bandwidth" should be lowercase everywhere, including config. |
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)? |
b25e979
to
3d60a0a
Compare
Looks good to me. Is there any reason you changed the bandwidth values in the integration test? Nice job, btw. |
611f02b
to
4a0971b
Compare
Oops... It is changed back now. Please take a look again when you have a chance, thanks! |
LGTM! Thanks! Now just need a second reviewer. |
back ref: kubernetes/kubernetes#63194 |
To make it easier to supply bandwidth in a dynamic manner, the traffic shaping plugin should support a capability arg.
Fixes: #133