~dimitern/goose/nova-runserver-base64

Viewing all changes in revision 41.

  • Committer: Ian Booth
  • Date: 2012-12-19 07:12:38 UTC
  • mfrom: (36.2.8 rate-limit-retries)
  • Revision ID: ian.booth@canonical.com-20121219071238-s3lcfpwg17fct3po
Retry OpenStack requests when throttled

When making a request to OpenStack, it may fail with a 413 if too many requests have been made in a period of time. In such cases, the response headers
will contain a Retry-After value indicating that the client and resend the request after X seconds. This branch enhances the Goose HTTP client to seamlessly
retry the request up to 3 times before it gives up.

Note that other times a 413 may be returned is when a resource limit truly has been exceeded, eg creating a floating ip adress. In this case, the request is not
resent and the call fails immediately.

A fair bit of refactoring in the HTTP client was required to get things in place to allow the request to be retried. I also modified the nova test suite to support
live and local testing so that I could ensure the test double could be made to generate 413s but then found that the nova test double stuff is not quite all landed yet. The
new testing stuff has been left in place though for when everything catches up.

I needed to capture the log output in the new test so added a Logger attribute to the HTTP client. If no logger is passed in, it defaults to the std Go logger.

The retry stuff in this branch fixes some previously broken tests. I modified the remaining broken tests to make them all pass against the live system. 
The only ones that fail now are the floating ip ones and then only if some ip addresses are allocated and left hanging around before the test is run.
We can look to make the tests clean up these perhaps.

R=jameinel
CC=
https://codereview.appspot.com/6920045

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: