On Mon, Jan 11, 2016 at 04:19:56PM +0100, 'Helga Velroyen' via ganeti-devel wrote: > This patch adds a backing-off mechanism to the function > RetryByNumberOfTimes. This is useful for example when SSH > connections fail in a flaky network. The original version of > RetryByNumberOfTimes immediately retried failed SSH calls, > but that might not be enough to recover from a network > problem. > > The patch adds an additional parameter 'backoff' which > specifies the base number of seconds of the backoff. That > means after the first failed try, a delay is added as long > as the backoff parameter specifies. With each additional > failed try, the delay is doubled until the maximum > number of retries is hit. > > Note that the backoff parameter is not a keyword argument, > which might have been more convenient. That's because > otherwise RetryByNumberOfTimes would no longer be able > to propagate *args and **kwargs to the function to be > called with retries. > > Also note that there is a function "Retry" in the same > package, which already provides somewhat complicated > timeout capabilities. However, we did not merge these > two functions, because Retry also does not propagate > *args and **kwargs properly which is something we > depend on in backend.py. > > This patch also updates the unit tests and mocks the > sleep function in the backend.py's unit tests to not > slow down the tests. > > This fixes issue 1078. > > Signed-off-by: Helga Velroyen <[email protected]> > --- > lib/backend.py | 18 +++++++++-------- > lib/utils/retry.py | 19 ++++++++++++++++- > test/py/ganeti.backend_unittest.py | 7 +++++++ > test/py/ganeti.utils.retry_unittest.py | 37 > ++++++++++++++++++++++++++++++---- > 4 files changed, 68 insertions(+), 13 deletions(-)
LGTM -- Klaus Aehlig Google Germany GmbH, Dienerstr. 12, 80331 Muenchen Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschaeftsfuehrer: Matthew Scott Sucherman, Paul Terence Manicle
