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

Batch EC2 DescribeInstances calls #1947

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

AndrewSirenko
Copy link
Contributor

@AndrewSirenko AndrewSirenko commented Feb 26, 2024

Is this a bug fix or adding new feature?
Feature

What is this PR about? / Why do we need it?
Coalesces EC2 DescribeInstances calls across ControllerPublishVolume/ControllerUnpublishVolume RPCs.

This decreases the likelihood of being exceeding one's Non-mutating API request token limit (ie being throttled for making too manyDescribe* calls).

What testing is done?
Manual testing on statefulset to check that DescribeInstances calls were batched across RPCs

CI

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 26, 2024
Copy link

Code Coverage Diff

File Old Coverage New Coverage Delta
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/cloud.go 81.6% 82.4% 0.8

Copy link
Member

@torredil torredil left a comment

Choose a reason for hiding this comment

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

/lgtm pending scalability tests before approval

Comment on lines -263 to +267
c := newEC2Cloud(region, awsSdkDebugLog, userAgentExtra)

if batching {
klog.V(4).InfoS("NewCloud: batching enabled")
cloudInstance, ok := c.(*cloud)
if !ok {
return nil, fmt.Errorf("expected *cloud type but got %T", c)
}
cloudInstance.bm = newBatcherManager(cloudInstance.ec2)
}

c := newEC2Cloud(region, awsSdkDebugLog, userAgentExtra, batching)
Copy link
Member

Choose a reason for hiding this comment

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

Nice! passing the batching status down the helper is much cleaner 👍

pkg/cloud/cloud.go Outdated Show resolved Hide resolved
pkg/cloud/cloud.go Outdated Show resolved Hide resolved
pkg/cloud/cloud.go Outdated Show resolved Hide resolved
return nil, r.Err
}
if r.Result == nil {
return nil, fmt.Errorf("batchDescribeInstances: no instance found %s", task) // TODO Q: Should this be Cloud's ErrNotFound instead?
Copy link
Member

Choose a reason for hiding this comment

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

TODO Q: Should this be Cloud's ErrNotFound instead?

Yes +1 to this, that error type is more appropriate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change batchDescribeVolumes as well then to be consistent.

pkg/cloud/cloud.go Outdated Show resolved Hide resolved
@AndrewSirenko
Copy link
Contributor Author

/retest

pkg/cloud/cloud.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ConnorJC3 ConnorJC3 left a comment

Choose a reason for hiding this comment

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

/lgtm

one nitpick

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2024
@AndrewSirenko
Copy link
Contributor Author

/hold

Waiting on scalability tests.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 28, 2024
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2024
@AndrewSirenko
Copy link
Contributor Author

Settled on 300ms instanceIDBatcher maxDelay by running scalability tests. We found that this value balanced minimizing amount of DescribeInstances EC2 calls and worst-case ControllerPublishVolume latency.

The table below shows total amount DescribeInstances API Calls made when attaching and detaching x volumes in a scalability test.

Unbatched 150ms 300ms 500ms
100 volumes 254 116 99 62
2500 volumes 6067 2298 1616 1312

@AndrewSirenko
Copy link
Contributor Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 1, 2024
@AndrewSirenko
Copy link
Contributor Author

/retest

Copy link
Member

@torredil torredil left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2024
@ConnorJC3
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ConnorJC3

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 4, 2024
@AndrewSirenko
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 142da92 into kubernetes-sigs:master Mar 4, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants