Merge lp:~mterry/ubuntuone-couch/dynamic-timeout into lp:ubuntuone-couch

Proposed by Michael Terry
Status: Merged
Approved by: dobey
Approved revision: 15
Merged at revision: 14
Proposed branch: lp:~mterry/ubuntuone-couch/dynamic-timeout
Merge into: lp:ubuntuone-couch
Diff against target: 18 lines (+4/-1)
1 file modified
ubuntuone/couch/auth.py (+4/-1)
To merge this branch: bzr merge lp:~mterry/ubuntuone-couch/dynamic-timeout
Reviewer Review Type Date Requested Status
dobey (community) Approve
Michael Terry (community) Abstain
Eric Casteleijn (community) Approve
Review via email: mp+69642@code.launchpad.net

Commit message

Allow 10s per megabyte in request before timing out

Description of the change

I was experiencing timeouts again in Deja Dup, which tries to upload backups in 25M chunks. The previous 10s timeout wasn't cutting it.

Then I realized that the timeout should probably scale with the size of the upload. So here's a branch that gives 10s per megabyte.

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks great, sorry for taking so long to respond, merge proposal got lost in the mail that my dog ate.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (8.4 KiB)

The attempt to merge lp:~mterry/ubuntuone-couch/dynamic-timeout into lp:ubuntuone-couch failed. Below is the output from the failed tests.

Running test suite for ubuntuone
ubuntuone.tests.test_couch
  QueryTestCase
    test_get_user_info ... [OK]
    test_get_user_info_404 ... [OK]
    test_request ... [OK]
    test_request_400 ... [OK]
    test_request_401 ... [OK]
    test_request_911 ... [OK]
    test_request_all_dbs ... [OK]
    test_request_all_dbs_with_extra_headers ... [OK]
    test_request_plaintext ... [OK]
    test_request_server_override ... [OK]
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntuone.tests.test_auth
  QueryTestCase
    test_get_oauth_credentials ... [OK]
    test_get_oauth_request_header ... [OK]
    test_get_oauth_request_header_http ... [OK]
    test_get_oauth_token ... [OK]
    test_request ... Traceback (most recent call last):
  File "/home/otto/tarmac-builds/ubuntuone-couch/trunk/ubuntuone/tests/test_auth.py", line 128, in test_request
    result = request('https://something.one.ubuntu.com/')
  File "/home/otto/tarmac-builds/ubuntuone-couch/trunk/ubuntuone/couch/auth.py", line 144, in request
    http = httplib2.Http(timeout=timeout, disable_ssl_certificate_validation=True)
  File "/usr/lib/pymodules/python2.7/mocker.py", line 1149, in __call__
    return self.__mocker_act__("call", args, kwargs)
  File "/usr/lib/pymodules/python2.7/mocker.py", line 1115, in __mocker_act__
    return path.execute(path.root_object)
  File "/usr/lib/pymodules/python2.7/mocker.py", line 1344, in execute
    object = action.execute(object)
  File "/usr/lib/pymodules/python2.7/mocker.py", line 1270, in execute
    result = object(*self.args, **self.kwargs)
exceptions.TypeError: __init__() got an unexpected keyword argument 'disable_ssl_certificate_validation'
[ERROR]
Traceback (most recent call last):
  File "/home/otto/tarmac-builds/ubuntuone-couch/trunk/ubuntuone/tests/test_auth.py", line 47, in tearDown
    self.mocker.verify()
  File "/usr/lib/pymodules/python2.7/mocker.py", line 579, in verify
    raise AssertionError(os.linesep.join(message))
exceptions.AssertionError: [Mocker] Unmet expectations:

=> httplib2.Http(timeout=10)
 - Performed fewer times than expected.

=> httplib2.Http(timeout=10).request('https://something.one.ubuntu.com/', body=None, headers=ANY, method='GET')
 - Performed fewer times than expected.

[ERROR]
    test_request_no_oauth_credentials ... ERROR:root:No credentials found in SSO. Credentials Not Found Error: missing key consumer_key
   ...

Read more...

Revision history for this message
Michael Terry (mterry) wrote :

Oh, sorry. I had accidentally included the contents of https://code.launchpad.net/~mterry/ubuntuone-couch/no-ssl-validation in this branch and didn't notice. Let me update this branch to remove that.

14. By Michael Terry

dynamically increase the http timeout for larger requests

Revision history for this message
Michael Terry (mterry) wrote :

OK, branch updated. Please re-review.

review: Needs Resubmitting
Revision history for this message
Michael Terry (mterry) wrote :

Changing vote to abstain.

review: Abstain
Revision history for this message
dobey (dobey) wrote :

Looks like you also need to update the tests. Seems a few are expecting timeout=10 to get passed in. They should probably expect Http(timeout=ANY) (from mocker import ANY).

[ERROR]
Traceback (most recent call last):
  File "/home/otto/tarmac-builds/ubuntuone-couch/trunk/ubuntuone/tests/test_auth.py", line 47, in tearDown
    self.mocker.verify()
  File "/usr/lib/pymodules/python2.7/mocker.py", line 579, in verify
    raise AssertionError(os.linesep.join(message))
exceptions.AssertionError: [Mocker] Unmet expectations:

=> httplib2.Http(timeout=10)
 - Performed fewer times than expected.

=> httplib2.Http(timeout=10).request('https://something.one.ubuntu.com/', body=None, headers=ANY, method='GET')
 - Performed fewer times than expected.

ubuntuone.tests.test_auth.QueryTestCase.test_request
ubuntuone.tests.test_auth.QueryTestCase.test_request_plaintext

review: Needs Fixing
15. By Michael Terry

add some more spaces to avoid lintian warnings

Revision history for this message
dobey (dobey) wrote :

OK. Perhaps the expectation errors were due to the ssl argument being there as well, and now that you've removed that, it's fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/couch/auth.py'
2--- ubuntuone/couch/auth.py 2011-05-25 14:04:22 +0000
3+++ ubuntuone/couch/auth.py 2011-08-09 13:17:31 +0000
4@@ -134,10 +134,13 @@
5 for key, value in urlparse.parse_qs(query).items():
6 parameters[key] = value[0]
7
8+ request_len = len(request_body) if request_body else 0
9+ timeout = 10 * (request_len / 1024 / 1024 + 1) # 10 seconds per megabyte
10+
11 oauth_header = get_oauth_request_header(
12 consumer, token, url, http_method, signature_method, parameters)
13 headers = headers or {}
14 headers.update(oauth_header)
15- http = httplib2.Http(timeout=10)
16+ http = httplib2.Http(timeout=timeout)
17 return http.request(
18 url, method=http_method, headers=headers, body=request_body)

Subscribers

People subscribed via source and target branches