client: add Kubernetes-aware retry helpers#2634
Conversation
|
Welcome @sttts! |
ee00eac to
ec56a76
Compare
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import asyncio |
There was a problem hiding this comment.
kuberentes/utils/ is for synchronous version of the client
kubernetes/aio/utils is for asynchronous version of the client
this file should not use asyncio, i think.
There was a problem hiding this comment.
it's for the default of the sleep func. But yes, I agree it should be the inverse.
There was a problem hiding this comment.
updated. Looks a lot better now: shared backoffs in base, linked into the sync and async variants. The aio helper implemented on-top. I.e. no duplicated code.
|
/assign @yliaog |
ec56a76 to
50d8aed
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sttts The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
50d8aed to
3e89602
Compare
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
|
Fixed in the latest push: I also verified |
| # Kubernetes Go retry algorithms used by client-go: | ||
| # - https://github.com/kubernetes/client-go/blob/master/util/retry/util.go | ||
| # - https://github.com/kubernetes/client-go/blob/master/rest/with_retry.go | ||
| async def async_on_error( |
There was a problem hiding this comment.
do we need async_ prefix in the function name? the function is under aio/utils, so it should be async to users. WDYT?
| raise last_error | ||
|
|
||
|
|
||
| async def async_retry_on_conflict( |
| backoff, is_conflict, fn, sleep_func, random_func) | ||
|
|
||
|
|
||
| async def async_on_retry_after_error( |
Summary
Add client-go-style retry helper APIs for the sync and AIO Python clients.
kubernetes/base/retry.py.kubernetes.utils.retry.kubernetes.aio.utils.retry.setup-asyncio.pyand the combinedsetup-release.pypackage list.The generated REST/Configuration wiring is intentionally separate and follows in kubernetes-client/gen#304.
Validation
.venv/bin/python -m unittest kubernetes.utils.retry_test kubernetes.aio.utils.retry_test.venv/bin/python -m pytest -q kubernetes/utils/retry_test.py kubernetes/aio/utils/retry_test.py.venv/bin/python -m pycodestyle ...for retry helpers, exports, andsetup-release.pysetup.py,setup-asyncio.py, andsetup-release.pybuild_pychecks confirmed symlinked helper files are copied as regular filesgit diff --check