From 32c23025ec4044de97f0c6ec0af0c10147901656 Mon Sep 17 00:00:00 2001 From: Laurent Bernaille Date: Fri, 7 Feb 2020 18:53:10 +0100 Subject: [PATCH] Default IPBatchSize to 1 (previous behavior) (#79) --- aws/interface.go | 11 +++++++---- plugin/ipam/main.go | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/aws/interface.go b/aws/interface.go index 5100a27..6c0dc09 100644 --- a/aws/interface.go +++ b/aws/interface.go @@ -61,12 +61,15 @@ func (c *interfaceClient) NewInterfaceOnSubnetAtIndex(index int, secGrps []strin if err != nil { return nil, err } - ipv4Limit := limits.IPv4 - 1 // batch size 0 conventionally means "request the limit" - if ipBatchSize == 0 || ipBatchSize > ipv4Limit { - createReq.SecondaryPrivateIpAddressCount = &ipv4Limit - } else { + if ipBatchSize == 0 || ipBatchSize > limits.IPv4 { + ipBatchSize = limits.IPv4 + } + + // We will already get a primary IP on the ENI + ipBatchSize = ipBatchSize - 1 + if ipBatchSize > 0 { createReq.SecondaryPrivateIpAddressCount = &ipBatchSize } diff --git a/plugin/ipam/main.go b/plugin/ipam/main.go index 10332ae..e997359 100644 --- a/plugin/ipam/main.go +++ b/plugin/ipam/main.go @@ -60,6 +60,7 @@ func init() { func parseConfig(stdin []byte) (*PluginConf, error) { conf := PluginConf{ ReuseIPWait: 60, // default 60 second wait + IPBatchSize: 1, // default 1 (backward compatibility) } if err := json.Unmarshal(stdin, &conf); err != nil {