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

[App Config] Throttling retry policy update - no retrying forever #16376

Merged
merged 15 commits into from
Jul 15, 2021

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Jul 14, 2021

Issue #16366

In this PR

  • Extending AppConfig client options with retry options with only maxRetries and the maxRetryDelay instead of all the four options of the RetryOptions interface in core-http
  • Update the custom throttling policy in app-config to not retry forever
  • And to make throttling retry policy honour maxRetries/maxRetryDelay

Fixes #16366

@ghost ghost added the App Configuration Azure.ApplicationModel.Configuration label Jul 14, 2021
@HarshaNalluru HarshaNalluru requested a review from jeremymeng July 14, 2021 03:03
@@ -2,7 +2,7 @@
"name": "@azure/app-configuration",
"author": "Microsoft Corporation",
"description": "An isomorphic client library for the Azure App Configuration service.",
"version": "1.2.0",
"version": "1.2.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why didnt the automation that increments version number do this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find it yesterday.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was filtering with App Configuration label and it turned out there was no label on the automated PR #16269.

Asked @praveenkuttappan in the teams' channel

@chradek
Copy link
Contributor

chradek commented Jul 14, 2021

Extending AppConfig client options with retry options with only maxRetries and the maxRetryDelay instead of all the four options of the RetryOptions interface in core-http

Why is retryDelayInMs excluded?

And to make throttling retry policy honour maxRetries/maxRetryDelay

I feel like this has been discussed, but is there an issue tracking honoring the retry count across retry policies (or consolidating retry policies into a single one that can keep track of the retry count)?

if (delayInMs == null) {
if (
delayInMs == null ||
(this.retryOptions.maxRetryDelayInMs && delayInMs > this.retryOptions.maxRetryDelayInMs)
Copy link
Member

Choose a reason for hiding this comment

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

should we just delay(maxRetryDelayInMs) for the case of (this.retryOptions.maxRetryDelayInMs && delayInMs > this.retryOptions.maxRetryDelayInMs)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@HarshaNalluru
Copy link
Member Author

HarshaNalluru commented Jul 14, 2021

Why is retryDelayInMs excluded?

retryDelayInMs is not for the throttlingRetryPolicy since we get the delay in ms from the error response from the service.

Eventually, we'll unify the retry policies in core.
Eventually, app-config will reuse what's present in core.

  • For that to happen, core has to allow/support parsing the "different" headers in the error response to get the delay in ms from the app-config service.
  • And core has to support retrying for the user-configured number of retries similar to what this PR does.

This current PR only cares about the throttling policy and is meant to unblock the customer.

I feel like this has been discussed, but is there an issue tracking honoring the retry count across retry policies (or consolidating retry policies into a single one that can keep track of the retry count)?

@chradek We'll get to that soon.. #9569

} from "@azure/core-http";
import { delay } from "@azure/core-http";

/**
* @internal
*/
export function throttlingRetryPolicy(): RequestPolicyFactory {
export function throttlingRetryPolicy(
retryOptions?: Pick<RetryOptions, "maxRetries" | "maxRetryDelayInMs">
Copy link
Member

Choose a reason for hiding this comment

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

update the parameter type to use the local one?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated!

constructor(
nextPolicy: RequestPolicy,
options: RequestPolicyOptions,
private retryOptions: Pick<RetryOptions, "maxRetries" | "maxRetryDelayInMs"> = {}
Copy link
Member

Choose a reason for hiding this comment

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

update the parameter type to use the local one?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated!


if (delayInMs == null) {
throw err;
}

if (
this.retryOptions.maxRetryDelayInMs &&
Copy link
Member

Choose a reason for hiding this comment

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

can we set this to the default in the constructor default option value? Otherwise the delay can go unbounded.

    private retryOptions: Pick<RetryOptions, "maxRetries" | "maxRetryDelayInMs"> = {
      maxRetryDelayInMs: 90*1000 // is this constant defined somewhere?
      maxRetries: DEFAULT_CLIENT_RETRY_COUNT
    }

Copy link
Member Author

@HarshaNalluru HarshaNalluru Jul 14, 2021

Choose a reason for hiding this comment

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

This is fine for maxRetries, will add that.
I don't want to define maxRetryDelayInMs since different services may have different values.

For example, with the observations from app-config, I have seen values anywhere between 20ms and 300000ms.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the throttlign policy case, if the error from the service is with the delay, then we use it for delay and throw directly otherwise. I don't think there is a case of unboundedness.

maxRetryDelayInMs should only be provided by the user according to me.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds fair. Please update the ref doc for maxRetryDelayInMs to remove the mentioning of default value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

Copy link
Member

@jeremymeng jeremymeng left a comment

Choose a reason for hiding this comment

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

one comment about the ref doc. otherwise looking good!

@HarshaNalluru HarshaNalluru enabled auto-merge (squash) July 15, 2021 18:04
@HarshaNalluru HarshaNalluru merged commit bf2b891 into Azure:main Jul 15, 2021
deyaaeldeen pushed a commit that referenced this pull request Jul 26, 2021
…6376)

* app-config throttlign retry policy fix - no retrying forever

* typo

* update versions

* Add changelog

* Update sdk/appconfiguration/app-configuration/CHANGELOG.md

* Update sdk/appconfiguration/app-configuration/CHANGELOG.md

* Redeclare RetryOptions

* API Report

* delay(maxRetryDelayInMs) for the case of (this.retryOptions.maxRetryDelayInMs && delayInMs > this.retryOptions.maxRetryDelayInMs)

* address feedback

* remove 90 seconds default
@HarshaNalluru HarshaNalluru deleted the harshan/app-config/issue/16366 branch August 4, 2021 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Configuration Azure.ApplicationModel.Configuration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[App Config] Expose retryOptions from app-config to make it configurable
6 participants