Skip to content
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

Change tryAssignIPs to assign up to configured WARM_IP_TARGET #1279

Merged
merged 1 commit into from
Jun 3, 2021

Conversation

jacksontj
Copy link
Contributor

What type of PR is this?

bug / feature

Which issue does this PR fix:
#1272

What does this PR do / Why do we need it:
Previously tryAssignIPs would always allocate all available IPs on the
ENI regardless of the number of IPs the node would want. A great
showcase of this behavior is on node bootstrap. Assuming we have a node
with maxIPsPerENI=30 and WARM_IP_TARGET=5, the following happens:

  • Node starts with single IP
  • tryAssignIPs allocates an additional 29 IPs
  • decreaseIPPool will release 29-5=24 IPs

After the change this would look like:

  • Node starts with a single IP
  • tryAssignIPs allocates an additional 5 IPs

So in this very common flow we cut out an entire AWS API call per node.
In addition this behavior exhibits itself any time we need to scale up
IPs as tryAssignIPs always attempts to over-allocate IPs -- which then
just need to be released almost immediately.

If an issue # is not available please add repro steps and logs from IPAMD/CNI showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades. Has updating a running cluster been tested?:

Does this change require updates to the CNI daemonset config files to work?:

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Previously tryAssignIPs would always allocate all available IPs on the
ENI regardless of the number of IPs the node would want. A great
showcase of this behavior is on node bootstrap. Assuming we have a node
with maxIPsPerENI=30 and WARM_IP_TARGET=5, the following happens:
- Node starts with single IP
- tryAssignIPs allocates an additional 29 IPs
- decreaseIPPool will release 29-5=24 IPs

After the change this would look like:
- Node starts with a single IP
- tryAssignIPs allocates an additional 5 IPs

So in this very common flow we cut out an entire AWS API call per node.
In addition this behavior exhibits itself any time we need to scale up
IPs as tryAssignIPs always attempts to over-allocate IPs -- which then
just need to be released almost immediately.

Fixes aws#1272
@jacksontj
Copy link
Contributor Author

cc @mogren

@jayanthvn
Copy link
Contributor

Hi @jacksontj

Please kindly fill the PR template and attach unit test cases - logs showing the functionality is working should be sufficient.

Appreciate your help on this. Thank you!

Copy link
Contributor

@nithu0115 nithu0115 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(lgtm) fwiw, we need to test if setting WARM_IP_TARGET as 5 and if I have 30 pending pods to be scheduled on a newly created node, and see if p99 of pod start time increases in this case and/or see if there are other any negative impacts.

Copy link
Contributor

@nithu0115 nithu0115 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(lgtm) fwiw, we need to test if setting WARM_IP_TARGET as 5 and if I have 30 pending pods to be scheduled on a newly created node, and see if p99 of pod start time increases in this case and/or see if there are other any negative impacts.

@jayanthvn
Copy link
Contributor

Also, can you please add mock up unit test cases something similar to ones here - https://github.com/aws/amazon-vpc-cni-k8s/blob/master/pkg/awsutils/awsutils_test.go. Thank you!

@jayanthvn
Copy link
Contributor

As @nithu0115 mentioned, we will test this change to verify if p99 pod start up time is increasing.

@jayanthvn jayanthvn requested a review from haouc March 1, 2021 22:59
// Find an ENI where we can add more IPs
eni := c.dataStore.GetENINeedsIP(c.maxIPsPerENI, c.useCustomNetworking)
if eni != nil && len(eni.IPv4Addresses) < c.maxIPsPerENI {
currentNumberOfAllocatedIPs := len(eni.IPv4Addresses)
// Try to allocate all available IPs for this ENI
err = c.awsClient.AllocIPAddresses(eni.ID, c.maxIPsPerENI-currentNumberOfAllocatedIPs)
err = c.awsClient.AllocIPAddresses(eni.ID, int(math.Min(float64(c.maxIPsPerENI-currentNumberOfAllocatedIPs), float64(toAllocate))))
Copy link
Contributor

@haouc haouc Mar 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have min() and max() defined in this file which can be used here without doing type conversion.

Copy link
Contributor

@M00nF1sh M00nF1sh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@M00nF1sh M00nF1sh merged commit 078bcb7 into aws:master Jun 3, 2021
@nithu0115
Copy link
Contributor

I cherry picked this PR on top of 1.7.10 release and tested it. The change is looks good to me.

Tested it with below 2 scenarios and saw expected behavior. One thing to note was, I saw an increase in number of AssignPrivateIpAddresses API calls as we are not going optimistic behavior anymore where we previously assumed that there were pending Pods.

Scenario1: Started with 1 node in the cluster and CNI configuration MINIMUM_IP_TARGET=5 and WARM_IP_TARGET=2 and launched 100 Pods.
Scenario2: WARM_IP_TARGET=2 and launched 100 Pods.

@jayanthvn jayanthvn added this to the v1.8.0 milestone Jun 3, 2021
M00nF1sh pushed a commit to M00nF1sh/amazon-vpc-cni-k8s that referenced this pull request Jun 7, 2021
Previously tryAssignIPs would always allocate all available IPs on the
ENI regardless of the number of IPs the node would want. A great
showcase of this behavior is on node bootstrap. Assuming we have a node
with maxIPsPerENI=30 and WARM_IP_TARGET=5, the following happens:
- Node starts with single IP
- tryAssignIPs allocates an additional 29 IPs
- decreaseIPPool will release 29-5=24 IPs

After the change this would look like:
- Node starts with a single IP
- tryAssignIPs allocates an additional 5 IPs

So in this very common flow we cut out an entire AWS API call per node.
In addition this behavior exhibits itself any time we need to scale up
IPs as tryAssignIPs always attempts to over-allocate IPs -- which then
just need to be released almost immediately.

Fixes aws#1272
M00nF1sh pushed a commit to M00nF1sh/amazon-vpc-cni-k8s that referenced this pull request Jun 7, 2021
Previously tryAssignIPs would always allocate all available IPs on the
ENI regardless of the number of IPs the node would want. A great
showcase of this behavior is on node bootstrap. Assuming we have a node
with maxIPsPerENI=30 and WARM_IP_TARGET=5, the following happens:
- Node starts with single IP
- tryAssignIPs allocates an additional 29 IPs
- decreaseIPPool will release 29-5=24 IPs

After the change this would look like:
- Node starts with a single IP
- tryAssignIPs allocates an additional 5 IPs

So in this very common flow we cut out an entire AWS API call per node.
In addition this behavior exhibits itself any time we need to scale up
IPs as tryAssignIPs always attempts to over-allocate IPs -- which then
just need to be released almost immediately.

Fixes aws#1272
M00nF1sh added a commit that referenced this pull request Jun 7, 2021
…#1495)

Previously tryAssignIPs would always allocate all available IPs on the
ENI regardless of the number of IPs the node would want. A great
showcase of this behavior is on node bootstrap. Assuming we have a node
with maxIPsPerENI=30 and WARM_IP_TARGET=5, the following happens:
- Node starts with single IP
- tryAssignIPs allocates an additional 29 IPs
- decreaseIPPool will release 29-5=24 IPs

After the change this would look like:
- Node starts with a single IP
- tryAssignIPs allocates an additional 5 IPs

So in this very common flow we cut out an entire AWS API call per node.
In addition this behavior exhibits itself any time we need to scale up
IPs as tryAssignIPs always attempts to over-allocate IPs -- which then
just need to be released almost immediately.

Fixes #1272

Co-authored-by: Thomas Jackson <jacksontj.89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants