From 524f508b27b92f8d7ec467b104e6bb72a14d7036 Mon Sep 17 00:00:00 2001 From: Claes Mogren Date: Thu, 13 Aug 2020 08:30:19 -0700 Subject: [PATCH] Move error log to after we check the message Even when AssignPrivateIpAddresses returns PrivateIpAddressLimitExceeded, we get the IPs assigned. Stop logging this as an error since we check later in ipamd.go for the IPs and retry if none were added. --- pkg/awsutils/awsutils.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/awsutils/awsutils.go b/pkg/awsutils/awsutils.go index 24ac975ff4..d9839c8723 100644 --- a/pkg/awsutils/awsutils.go +++ b/pkg/awsutils/awsutils.go @@ -1224,12 +1224,13 @@ func (cache *EC2InstanceMetadataCache) AllocIPAddresses(eniID string, numIPs int output, err := cache.ec2SVC.AssignPrivateIpAddressesWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("AssignPrivateIpAddresses", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { - log.Errorf("Failed to allocate a private IP addresses on ENI %v: %v", eniID, err) - awsAPIErrInc("AssignPrivateIpAddresses", err) if containsPrivateIPAddressLimitExceededError(err) { - log.Debug("AssignPrivateIpAddresses returned PrivateIpAddressLimitExceeded") + log.Debug("AssignPrivateIpAddresses returned PrivateIpAddressLimitExceeded, but this is usually not true." + + "Returning nil, since we will check again by calling EC2 to get what addresses were assigned to the ENI.") return nil } + log.Errorf("Failed to allocate a private IP addresses on ENI %v: %v", eniID, err) + awsAPIErrInc("AssignPrivateIpAddresses", err) return errors.Wrap(err, "allocate IP address: failed to allocate a private IP address") } if output != nil {