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

Azure - ARM Read/Write rate limiting #59830

Merged
merged 7 commits into from
Feb 16, 2018
Merged

Azure - ARM Read/Write rate limiting #59830

merged 7 commits into from
Feb 16, 2018

Conversation

khenidak
Copy link
Contributor

@khenidak khenidak commented Feb 13, 2018

What this PR does / why we need it:

Azure cloud provider currently runs with:

  1. Single ARM rate limiter for both read [put/post/delete] and write operations, while ARM provide [different rates for read/write] (https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits). This causes write operation to stop even if there is available write request quotas.
  2. Cloud provider uses rate limiter's Accept() instead of TryAccept() This causes control loop to wait for prolonged tike in case of no request quota available for all requests even for those does not require ARM interaction. A case for that the Service control loop will wait for a prolonged time trying to create LoadBalancer service even though it can fail and work on the next service which is ClusterIP. This PR moves cloud provider tp TryAccept()

Which issue(s) this PR fixes:
Fixes # #58770

Special notes for your reviewer:
n/a

Release note:

- Separate current ARM rate limiter into read/write
- Improve control over how ARM rate limiter is used within Azure cloud provider

cc @jackfrancis (need your help carefully reviewing this one) @brendanburns @jdumars

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 13, 2018
@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Feb 13, 2018
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 13, 2018
@k8s-github-robot k8s-github-robot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Feb 13, 2018
@khenidak khenidak changed the title WIP: Azure - ARM Read/Write rate limiting Azure - ARM Read/Write rate limiting Feb 13, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 13, 2018
@khenidak
Copy link
Contributor Author

@jackfrancis @brendanburns This is ready for review now.

az.rateLimiter.Accept()
err = createArmRateLimitErr(false, "VMGet")
if !az.rateLimiterReader.TryAccept() {
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Educate me in golang. :)

By implicitly returning (simple return without params) both named return types, what are we returning as the value of result in the error case?

@@ -181,7 +209,11 @@ func (az *azVirtualMachinesClient) Get(resourceGroupName string, VMName string,
}

func (az *azVirtualMachinesClient) List(resourceGroupName string) (result compute.VirtualMachineListResult, err error) {
az.rateLimiter.Accept()
err = createArmRateLimitErr(false, "VMList")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we optimize by putting these err constructor invocations inside the failure condition if block (as they are only used if the failure condition is met)?

@jackfrancis
Copy link
Contributor

@khenidak Added a couple comments for thought. Overall lgtm, audited all the rate limit injections (esp. the write ones which require us to compose a zero value return value) and they look correct/sane.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2018
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2018
@khenidak
Copy link
Contributor Author

@jackfrancis updated with your code comments PTAL
@feiskyer I have had to merge the VMSS code. can you do a sanity check?

Copy link
Contributor

@jackfrancis jackfrancis left a comment

Choose a reason for hiding this comment

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

lgtm

@jdumars
Copy link
Member

jdumars commented Feb 15, 2018

@feiskyer if you're good with this implementation can you add the LGTM so we can get this merged?

@@ -33,6 +34,15 @@ import (
"k8s.io/client-go/util/flowcontrol"
)

// Creates an error for rate limiting errors
func createArmRateLimitErr(isWrite bool, opName string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that the purpose of this is to return this error in a channel, perhaps having this signature being:

Also nit, golang style says Arm should be ARM.

func createARMRateLimitError(isWrite bool, opName string) (err, chan error) {

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I actually see that you use this elsewhere, perhaps two functions:

func createARMRateLimitError(...) error {

and

func createARMRateLimitErrChannel() chan error {

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 15, 2018
@khenidak
Copy link
Contributor Author

@brendanburns code comments addressed. Thanks

Copy link
Member

@feiskyer feiskyer 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 Feb 15, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feiskyer, khenidak

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-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 59939, 59830). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 271c267 into kubernetes:master Feb 16, 2018
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

7 participants