in pkg/ipamd/ipamd.go [763:819]
func (c *IPAMContext) increaseDatastorePool(ctx context.Context) {
log.Debug("Starting to increase pool size")
ipamdActionsInprogress.WithLabelValues("increaseDatastorePool").Add(float64(1))
defer ipamdActionsInprogress.WithLabelValues("increaseDatastorePool").Sub(float64(1))
short, _, warmIPTargetDefined := c.datastoreTargetState()
if warmIPTargetDefined && short == 0 {
log.Debugf("Skipping increase Datastore pool, warm target reached")
return
}
if !warmIPTargetDefined {
shortPrefix, warmTargetDefined := c.datastorePrefixTargetState()
if warmTargetDefined && shortPrefix == 0 {
log.Debugf("Skipping increase Datastore pool, warm prefix target reached")
return
}
}
if c.isTerminating() {
log.Debug("AWS CNI is terminating, will not try to attach any new IPs or ENIs right now")
return
}
// Try to add more Cidrs to existing ENIs first.
if c.inInsufficientCidrCoolingPeriod() {
log.Debugf("Recently we had InsufficientCidr error hence will wait for %v before retrying", insufficientCidrErrorCooldown)
return
}
increasedPool, err := c.tryAssignCidrs()
if err != nil {
log.Errorf(err.Error())
if containsInsufficientCIDRsOrSubnetIPs(err) {
log.Errorf("Unable to attach IPs/Prefixes for the ENI, subnet doesn't seem to have enough IPs/Prefixes. Consider using new subnet or carve a reserved range using create-subnet-cidr-reservation")
c.lastInsufficientCidrError = time.Now()
return
}
}
if increasedPool {
c.updateLastNodeIPPoolAction()
} else {
// Check if we need to make room for the VPC Resource Controller to attach a trunk ENI
reserveSlotForTrunkENI := 0
if c.enablePodENI && c.dataStore.GetTrunkENI() == "" {
reserveSlotForTrunkENI = 1
}
// If we did not add an IP, try to add an ENI instead.
if c.dataStore.GetENIs() < (c.maxENI - c.unmanagedENI - reserveSlotForTrunkENI) {
if err = c.tryAllocateENI(ctx); err == nil {
c.updateLastNodeIPPoolAction()
}
} else {
log.Debugf("Skipping ENI allocation as the max ENI limit of %d is already reached (accounting for %d unmanaged ENIs and %d trunk ENIs)",
c.maxENI, c.unmanagedENI, reserveSlotForTrunkENI)
}
}
}