-
Notifications
You must be signed in to change notification settings - Fork 741
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
Add config option for number of ENIs get preallocated #68
Conversation
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.
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.
@@ -117,6 +120,8 @@ func New() (*IPAMContext, error) { | |||
|
|||
//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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Glad to see we're tracking pending actions now.
@@ -260,6 +265,10 @@ func (c *IPAMContext) increaseIPPool() { | |||
return | |||
} | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be simpler with sprintf
. eg:
errString = fmt.sprintf("desired: %d, current: %d", maxENIs, c.maxENI)
ipamd/ipamd.go
Outdated
|
||
return ((total - used) <= c.currentMaxAddrsPerENI) | ||
return ((total - used) <= c.currentMaxAddrsPerENI*preAllocENIs) |
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.
pls put spaces around *
for readability.
ipamd/ipamd.go
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some whitespace
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/number of maximum IPs can/maximum number of IP addresses that can/
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.
please correct as advised. this is user facing description, let's get the grammar right.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be consistent on your use of spaces around =
ipamd/ipamd.go
Outdated
|
||
return ((total - used) <= c.currentMaxAddrsPerENI) | ||
return ((total - used) <= c.currentMaxAddrsPerENI*warmENITarget) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
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.
ditto
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please correct as advised. this is user facing description, let's get the grammar right.
3960987
to
96d2d7a
Compare
96d2d7a
to
90c3243
Compare
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.
Ship it!
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.