Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: googleapis/python-api-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: vam-google/python-api-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 12 commits
  • 34 files changed
  • 3 contributors

Commits on Oct 19, 2022

  1. fix: Major refactoring and fix for Polling, Retry and Timeout logic

    This is in response to https://freeman.vc/notes/aws-vs-gcp-reliability-is-wildly-different, which triggered an investigation of the whole Polling/Retry/Timeout behavior in Python GAPIC clients and revealed many fundamental flaws in its implementaiton.
    
    To properly describe the refactoring this PR does we need to stick to a rigorous terminology, as vague definitions of retries, timeouts, polling and related concepts seems to be the main source of the present bugs and overal confusion among both groups: users of the library and creators of the library. Please check the documentation of the `google.api_core.retry.Retry` class the `google.api_core.future.polling.Polling.result()` method for the proper definitions and context.
    
    Note, the overall semantics around Polling, Retry and Timeout remains quite confusing even after refactoring (although it is now more or less rigorously defined), but it was clean as I could make it while still maintaining backward compatibility of the whole library.
    
    The quick summary of the changes in this PR:
    
    1) Properly define and fix the application of Deadline and Timeout concepts. Please check the updated documentation for the `google.api_core.retry.Retry` class for the actual definitions. Originally the `deadline` has been used to represent timeouts conflating the two concepts. As result this PR replaces `deadline` arguments with `timeout` ones in as backward-compatible manner as possible (i.e. backward compatible in all practical applications).
    
    2) Properly define RPC Timeout, Retry Timeout and Pollint Timeout and how a generic Timeout concept (aka Logical Timeout) is mapped to one of those depending on the context. Please check `google.api_core.retry.Retry` class documentation for details.
    
    3) Properly define and fix the application of Retry and Polling concepts. Please check the updated documentation for `google.api_core.future.polling.PollingFuture.result()` for details.
    
    4) Separate `retry` and `polling` configurations for Polling future, as these are two different concepts (although both operating on `Retry` class). Originally both retry and polling configurations were controlled by a single `retry` parameter, merging configuration regarding how "rpc error responses" and how "operation not completed" responses are supposed to be handled.
    
    5) For the following config properties - `Retry (including `Retry Timeout`), `Polling` (including `Polling Timeout`) and `RPC Timeout` - fix and properly define how each of the above properties gets configured and which config gets precedence in case of a conflict (check `PollingFuture.result()` method documentation for details). Each of those properties can be specified as follows: directly provided by the user for each call, specified during gapic generation time from config values in `grpc_service_config.json` file (for Retry and RPC Timeout) and `gapic.yaml` file (for Polling), or be provided as a hard-coded basic default values in python-api-core library itself.
    
    6) Fix the per-call polling config propagation logic (the polling/retry configs supplied to `PollingFuture.result()` used to be ignored for actual call).
    
    7) Deprecate the usage of `deadline` terminology in the whole library and backward-compatibly replace it with timeout. This is essential as what has been called "deadline" in this library was actually "timeout" as it is defined in `google.api_core.retry.Retry` class documentation.
    
    8) Deprecate `ExponentialTimeout`, `ConstantTimeout` and related logic as those are outdated concepts and are not consistent with the other GAPIC Languages. Replace it with `TimeToDeadlineTimeout` to be consistent with how the rest of the languages do it.
    
    9) Deprecate `google.api_core.operations_v1.config` as it is an outdated concept and self-inconsistent (as all gapic clients provide configuraiton in code). The configs are directly provided in code instead.
    
    10) Switch randomized delay calculation from `delay` being treated as expected value for randomized_delay to `delay` being treated as maximum value for `randomized_delay` (i.e. the new expected valud for `randomized_delay` is `delay / 2`). See the `exponential_sleep_generator()` method implementation for details. This is needed to make Python implementation of retries and polling exponential backoff consistent with the rest of GAPIC languages. Also fix the uncontrollable growth of `delay` value (since it is a subject of exponential growth, the `delay` value was quickly reaching "infinity" value, and the whole thing was not failing simply due to python being a very forgiving language which forgives multiplying "infinity" by a number (`inf * number = inf`) binstead of simply overflowing to a (most likely) negative number).
    
    11) Fix url construction in `OperationsRestTransport`. Without this fix the polling logic for REST transport was completely broken (is not affecting Compute client, as that one has custom LRO).
    
    12) Las but not least: change the default values for Polling logic to be the following: `initial=1.0` (same as before), `maximum=20.0` (was `60`), `multiplier=1.5` (was `2.0`), `timeout=900` (was `120`, but due to timeout resolution logic was actually None (i.e. infinity)). This, in conjunction with changed calculation of randomized delay (i.e. its expected value now being  `delay / 2`) overall makes polling logic much less aggressive in terms of increasing delays between each polling iteration, making LRO return much earlier for users on average, but still keeping a healthy balance between strain put on both client and server by polling and responsiveness of LROs for user.
    
    *The design doc summarising all the changes and reasons for them is in progress.
    vam-google committed Oct 19, 2022
    Configuration menu
    Copy the full SHA
    94e4c21 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6a63d34 View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2022

  1. remove unused code

    vam-google committed Oct 31, 2022
    Configuration menu
    Copy the full SHA
    ea8b176 View commit details
    Browse the repository at this point in the history
  2. fix typo

    vam-google committed Oct 31, 2022
    Configuration menu
    Copy the full SHA
    ad03684 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    eba0f38 View commit details
    Browse the repository at this point in the history
  4. reformat code

    vam-google committed Oct 31, 2022
    Configuration menu
    Copy the full SHA
    23c02c6 View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2022

  1. address pr feedback

    vam-google committed Nov 1, 2022
    Configuration menu
    Copy the full SHA
    ac0d65f View commit details
    Browse the repository at this point in the history
  2. address PR feedback

    vam-google committed Nov 1, 2022
    Configuration menu
    Copy the full SHA
    cb7a0b2 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2022

  1. address pr feedback

    vam-google committed Nov 2, 2022
    Configuration menu
    Copy the full SHA
    fc72914 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2022

  1. Update google/api_core/future/polling.py

    Co-authored-by: Victor Chudnovsky <[email protected]>
    vam-google and vchudnov-g authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    a5a5f2e View commit details
    Browse the repository at this point in the history
  2. Apply documentation suggestions from code review

    Co-authored-by: Victor Chudnovsky <[email protected]>
    vam-google and vchudnov-g authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    15db4b4 View commit details
    Browse the repository at this point in the history
  3. Address PR feedback

    vam-google committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    e382041 View commit details
    Browse the repository at this point in the history
Loading