From 119f25a69664d9e554bf6ffe6087beaa38476b02 Mon Sep 17 00:00:00 2001 From: Jayanth Varavani <1111446+jayanthvn@users.noreply.github.com> Date: Fri, 12 Jun 2020 20:41:51 +0000 Subject: [PATCH] incorporated the review comments and made a null sanity check --- pkg/awsutils/awsutils.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/awsutils/awsutils.go b/pkg/awsutils/awsutils.go index 9e582d0f4d..15c523eae9 100644 --- a/pkg/awsutils/awsutils.go +++ b/pkg/awsutils/awsutils.go @@ -1004,6 +1004,9 @@ func (cache *EC2InstanceMetadataCache) DescribeAllENIs() ([]ENIMetadata, map[str // Collect ENI response into ENI metadata and tags. tagMap := make(map[string]TagMap, len(ec2Response.NetworkInterfaces)) for _, ec2res := range ec2Response.NetworkInterfaces { + if ec2res.Attachment != nil && aws.Int64Value(ec2res.Attachment.DeviceIndex) == 0 && !aws.BoolValue(ec2res.Attachment.DeleteOnTermination) { + log.Warn("Primary ENI will not get deleted when node terminates because 'delete_on_termination' is set to false") + } eniID := aws.StringValue(ec2res.NetworkInterfaceId) eniMetadata := eniMap[eniID] // Check IPv4 addresses @@ -1019,9 +1022,6 @@ func (cache *EC2InstanceMetadataCache) DescribeAllENIs() ([]ENIMetadata, map[str if len(tags) > 0 { tagMap[eniMetadata.ENIID] = tags } - if aws.Int64Value(ec2res.Attachment.DeviceIndex) == 0 && !aws.BoolValue(ec2res.Attachment.DeleteOnTermination) { - log.Warn("Primary ENI will not get deleted when node terminates because 'delete_on_termination' is set to false") - } } return verifiedENIs, tagMap, nil }