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

feat: add azure zone list cache #4811

Merged

Conversation

tanujd11
Copy link
Contributor

@tanujd11 tanujd11 commented Oct 16, 2024

Description

zoneListCache is introduced for Azure so that the azure ratelimiting can be countered with for this particular call. Although the ratelimit is higher for this particular call but in Azure there are some ratelimiters which are shared between various services for example this particular one comes in microsoft.network API provider. This has resulted in some API ratelimiting for this particular call for me even with a relatively lesser number of external DNS running(8). This particular call need not run on all the external DNS reconciliation anyways, it will improve the speed of the reconciliation as well.

Error is mentioned below:

Failed to do run once: GET https://management.azure.com/subscriptions/9a42948e-6087-47d2-bdb8-b530d558db22/resourceGroups/glbdemo01-global/providers/Microsoft.Network/privateDnsZones\n--------------------------------------------------------------------------------\nRESPONSE 429: 429 Too Many Requests\nERROR CODE UNAVAILABLE\n--------------------------------------------------------------------------------\n\"{\\\"code\\\":\\\"Throttled\\\",\\\"message\\\":\\\"Too many operations are requested. Current operation is throttled.\\\"}\"\n--------------------------------------------------------------------------------\n"

Fixes #ISSUE

Checklist

  • Unit tests updated
  • End user documentation updated

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 16, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @tanujd11. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 16, 2024
}
}

// Get method to retrieve the cached zones
Copy link
Contributor

Choose a reason for hiding this comment

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

comments should add more value than writing what you can read.
In this example you can add if it's a shallow copy or not for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have added more concrete lines. Thanks

return z.zones
}

// Expired method to check if the cache has expired based on duration or if zones are empty
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we check for len(zones) would be interesting for the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, PTAL


// Expired method to check if the cache has expired based on duration or if zones are empty
func (z *zonesCache[T]) Expired() bool {
return len(z.zones) < 1 || time.Since(z.age) > z.duration
Copy link
Contributor

Choose a reason for hiding this comment

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

Why z.age and not time.Now() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

z.age is the time of last update. Basically the time passed since last update, if it is greater than the allowed duration, then we invalidate the cache. I am not sure what you mean how time.Now() will work here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah sorry makes sense

provider/azure/cache.go Show resolved Hide resolved
@szuecs
Copy link
Contributor

szuecs commented Oct 16, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 16, 2024
@tanujd11 tanujd11 requested a review from szuecs October 17, 2024 07:34
docs/tutorials/azure.md Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 18, 2024
@szuecs
Copy link
Contributor

szuecs commented Oct 18, 2024

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: szuecs

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 merged commit 60ba543 into kubernetes-sigs:master Oct 18, 2024
13 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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