Add config option for number of ENIs get preallocated#68
Add config option for number of ENIs get preallocated#68liwenwu-amazon merged 1 commit intoaws:masterfrom
Conversation
dbenhur
left a comment
There was a problem hiding this comment.
mostly nits, but I'm confused by the threshold. I think we need an issue to make the warm address management driven by desired pool size and move away from eni centric logic.
| //TODO need to break this function down(comments from CR) | ||
| func (c *IPAMContext) nodeInit() error { | ||
| ipamdActionsInprogress.WithLabelValues("nodeInit").Add(float64(1)) | ||
| defer ipamdActionsInprogress.WithLabelValues("nodeInit").Sub(float64(1)) |
There was a problem hiding this comment.
Nice. Glad to see we're tracking pending actions now.
| } | ||
| if (c.maxENI > 0) && (c.maxENI == c.dataStore.GetENIs()) { | ||
| if c.maxENI < maxENIs { | ||
| errString := "desired: " + strconv.FormatInt(int64(maxENIs), 10) + "current: " + strconv.FormatInt(int64(c.maxENI), 10) |
There was a problem hiding this comment.
this would be simpler with sprintf. eg:
errString = fmt.sprintf("desired: %d, current: %d", maxENIs, c.maxENI)
ipamd/ipamd.go
Outdated
| total, used, c.currentMaxAddrsPerENI, c.maxAddrsPerENI, preAllocENIs) | ||
|
|
||
| return ((total - used) <= c.currentMaxAddrsPerENI) | ||
| return ((total - used) <= c.currentMaxAddrsPerENI*preAllocENIs) |
There was a problem hiding this comment.
pls put spaces around * for readability.
ipamd/ipamd.go
Outdated
| preAllocENIs := getPreAllocENILimit() | ||
| total, used := c.dataStore.GetStats() | ||
| log.Debugf("IP pool stats: total=%d, used=%d, c.currentMaxAddrsPerENI =%d, c.maxAddrsPerENI = %d, preAllocENIs", | ||
| total, used, c.currentMaxAddrsPerENI, c.maxAddrsPerENI, preAllocENIs) |
There was a problem hiding this comment.
We produce this IP pool stats message in multiple locations. Please extract to a function so it stays consistent everywhere.
ipamd/ipamd.go
Outdated
| total, used, c.currentMaxAddrsPerENI, c.maxAddrsPerENI) | ||
|
|
||
| return (total-used > 2*c.currentMaxAddrsPerENI) | ||
| return (total-used > (preAllocENIs+1)*c.currentMaxAddrsPerENI) |
There was a problem hiding this comment.
It's hard to understand why this is the threshold. Why does pre allocation effect whether we have too many available addrs other than setting a floor? I still think all this management would be better expressed with a desired address-warm-pool-buffer size, and derive eni requirements from that.
e5a9976 to
1d2873c
Compare
ipamd/ipamd.go
Outdated
| ipMax = prometheus.NewGauge( | ||
| prometheus.GaugeOpts{ | ||
| Name: "ip_max", | ||
| Help: "The number of maximum IPs can be allocated to the instance", |
There was a problem hiding this comment.
s/number of maximum IPs can/maximum number of IP addresses that can/
There was a problem hiding this comment.
please correct as advised. this is user facing description, let's get the grammar right.
There was a problem hiding this comment.
These are "private IPv4 addresses". Not "IPs". Even the internal-facing strings/objects should be properly named.
ipamd/ipamd.go
Outdated
| } | ||
|
|
||
| func logPoolStats(total, used, currentMaxAddrsPerENI, maxAddrsPerENI int) { | ||
| log.Debugf("IP pool stats: total=%d, used=%d, c.currentMaxAddrsPerENI =%d, c.maxAddrsPerENI = %d", |
There was a problem hiding this comment.
be consistent on your use of spaces around =
ipamd/ipamd.go
Outdated
| logPoolStats(total, used, c.currentMaxAddrsPerENI, c.maxAddrsPerENI) | ||
|
|
||
| return ((total - used) <= c.currentMaxAddrsPerENI) | ||
| return ((total - used) <= c.currentMaxAddrsPerENI*warmENITarget) |
There was a problem hiding this comment.
this would be clearer if you said available := total - used then made the comparison against available. add space around ' * '.
There was a problem hiding this comment.
go fmt removes spaces around '*'
ipamd/ipamd.go
Outdated
| total, used, c.currentMaxAddrsPerENI, c.maxAddrsPerENI) | ||
|
|
||
| return (total-used > 2*c.currentMaxAddrsPerENI) | ||
| return (total-used > (warmENITarget+1)*c.currentMaxAddrsPerENI) |
ipamd/ipamd.go
Outdated
| maxENIs, err := c.awsClient.GetENILimit() | ||
| enisMax.Set(float64(maxENIs)) | ||
| maxIPs, err := c.awsClient.GetENIipLimit() | ||
| ipMax.Set(float64(maxIPs * int64(maxENIs))) |
There was a problem hiding this comment.
These can get an error which the code completely ignores.
1d2873c to
26a41ba
Compare
ipamd/ipamd.go
Outdated
| ipMax = prometheus.NewGauge( | ||
| prometheus.GaugeOpts{ | ||
| Name: "ip_max", | ||
| Help: "The number of maximum IPs can be allocated to the instance", |
There was a problem hiding this comment.
please correct as advised. this is user facing description, let's get the grammar right.
3960987 to
96d2d7a
Compare
96d2d7a to
90c3243
Compare
Description of changes
Current Behavior
Today, ipamD dynamically allocate and free ENIs based on the number Pods running on the node.
It allocates one more ENI when the number of available IP addresses goes below the per ENI's secondary IP limit. It can free an ENI when the number of available IP addresses grows more than 2 * per ENI's secondary IP limit.
For example, for c3.xlarge, each ENI have 14 secondary IPs. When there is one ENI attached to the instance(e.g. when the instance is first booted) and after 8 pods just get scheduled to run on this node. The available IPs becomes 6 (14-8) and this will trigger ipamD allocating a new ENI.
Requirements
There are 3 different deployment scenarios requires 3 different triggering threshold:
New Behavior
This PR add config option which allow user to define the number of ENIs get allocated. If the config option is not defined, it is default to today's behavior
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.