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: make backoff_max configurable with default of 120 #2393

Conversation

barrett-schonefeld
Copy link

I work in the IBM Cloud Developer Experience group, and we use this package in our Python SDK "core" library (an enabling layer that is a dependency of our various IBM Cloud Python SDKs).

This message is adapted from an issue we posted in a package we use as a dependency for our Node SDK "core" library. As a reference, the message is adapted from this issue.

We want to use the exponential backoff policy, but also be able to cap the backoff time by some user-configurable amount. It looks like the package supports a default BACKOFF_TIME of 120. I would like to utilize this BACKOFF_TIME of 120 as the default value and allow users to configure this value as well.

This contribution is parallel to the contribution we made to the Node package in this PR.

@barrett-schonefeld barrett-schonefeld force-pushed the configurable-backoff-max branch 2 times, most recently from 37dc408 to 434d06c Compare August 27, 2021 20:25
Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

I think this makes sense to add. Having class-level setting be the only method to configure this isn't great because it impacts all usages of urllib3. The current CI looks like it's failing along with lint, you should run nox -s format to make sure your code is formatted properly and doesn't have type errors.

#: Maximum backoff time.
BACKOFF_MAX = 120
#: Default maximum backoff time.
DEFAULT_BACKOFF_MAX = 120
Copy link
Member

Choose a reason for hiding this comment

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

This change makes sense, however I think we'd need a deprecation cycle in v1.26.x to remove BACKOFF_MAX safely in v2.0. Perhaps we can do that since it's likely not used often.

In 1.26.x I'm thinking we can go the route of other deprecated Retry classvars: #2000

Copy link
Author

Choose a reason for hiding this comment

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

Ok, great!

To be sure I understand the process, we need a PR to deprecate BACKOFF_MAX. The deprecation change will be included in v1.26.x.

Then this PR (including DEFAULT_BACKOFF_MAX) will be introduced in 2.0.0.

Copy link
Member

Choose a reason for hiding this comment

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

You understand perfectly, once that PR exists and is merged we can merge this PR.

src/urllib3/util/retry.py Show resolved Hide resolved
src/urllib3/util/retry.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 30, 2021

Codecov Report

Merging #2393 (dcd2f40) into main (384feec) will not change coverage.
The diff coverage is 100.00%.

❗ Current head dcd2f40 differs from pull request most recent head 2c156a4. Consider uploading reports for the commit 2c156a4 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##              main     #2393   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         2478      2479    +1     
=========================================
+ Hits          2478      2479    +1     
Impacted Files Coverage Δ
src/urllib3/util/retry.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 384feec...2c156a4. Read the comment docs.

@barrett-schonefeld
Copy link
Author

Hey, folks, checking in on this PR!

How might I help get this work ready to be merged?

Also, would it be incorrect to leave BACKOFF_MAX as BACKOFF_MAX instead of changing this to DEFAULT_BACKOFF_MAX, so that we may more quickly release this update to make the backoff max configurable?

@sethmlarson
Copy link
Member

sethmlarson commented Sep 13, 2021

@barrett-schonefeld Thanks for the patience here, to answer your questions:

Would it be incorrect to leave BACKOFF_MAX as BACKOFF_MAX instead of changing this to DEFAULT_BACKOFF_MAX

I'm fine with keeping this value as BACKOFF_MAX but since it's going in v2.0 it might be good to get the naming right.

...so that we may more quickly release this update to make the backoff max configurable?

Unfortunately the 1.x release stream isn't receiving releases including new non-critical features. We're focusing completely on v2.0 so this likely won't be released until then. We don't have a date we're targetting for v2.0 as there still some large TODOs on our plate. Hopefully this doesn't discourage you from contributing this feature.

Copy link
Member

@sethmlarson sethmlarson 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, once we have the PR targeting 1.26.x we can merge this.

In addition we'll want to create a newsfragment, see this directory for examples on how to do so: https://github.com/urllib3/urllib3/tree/main/changelog Let me know if you have questions about this, your fragment should be named 2393.feature.rst and include the change for Retry.BACKOFF_MAX -> Retry.DEFAULT_BACKOFF_MAX and mention the new backoff_max parameter.

test/test_retry.py Show resolved Hide resolved
@barrett-schonefeld
Copy link
Author

In addition we'll want to create a newsfragment

Updated the test and add to the changelog!

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Can you please use past tense in the changelog entry as mentioned in https://github.com/urllib3/urllib3/blob/main/changelog/README.rst? (Wasn't clear from the contributing docs, so I updated them: #2415)

As you know, we'll also need the PR targeting the 1.26.x branch deprecating the old attribute first. You can look at #2000 for inspiration.

Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

After implementing @pquentin's comments (normalize changelog entry, open 1.26.x PR) this PR should be ready to merge.

@sethmlarson
Copy link
Member

@barrett-schonefeld We're still interested in landing this, but we haven't heard from you in some time, are you still interested in this PR?

@pyrooka
Copy link
Contributor

pyrooka commented Nov 19, 2021

Hi @sethmlarson! I am working in the same team as Barrett was working before he left IBM. We are still interested in this feature, so I will probably take over this PR. How should we do this? Since we cannot reach Barrett I think I should create a new branch with his changes and open a new PR?

@pquentin
Copy link
Member

Right, please open a new PR, we'll close this one. Thanks!

@pyrooka
Copy link
Contributor

pyrooka commented Nov 30, 2021

I opened the new PRs (#2494, #2495) yesterday, so this can be closed.

@pquentin pquentin closed this Dec 1, 2021
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.

None yet

4 participants