bodhi_utils: use internal retry logic
ClosedPublic

Authored by kparal on Jul 23 2015, 7:59 AM.

Details

Summary

Instead of having a custom retry code just for query_update(), make
use of the internal .retries attribute that applies to all Bodhi
requests. It also simplifies our code.

Our custom retry code was introduced in b1d4de312. At that time, we
didn't know about internal retry code (it's hidden inside
fedora.client.ProxyClient). I discovered it recently, it makes sense
to use it instead.

Test Plan

test suite adjusted. Tested manually in ipython and with upgradepath. In ipython:

import fedora.client
b = fedora.client.BodhiClient(base_url='http://httpstat.us')
b.retries = 3
import logging
logging.basicConfig()
b.log.setLevel(0logging.getLogger().setLevel(0)
b.send_request('503')

DEBUG:fedora.client.baseclient:No session cached for "None"
DEBUG:fedora.client.baseclient:proxyclient.send_request: entered
DEBUG:fedora.client.baseclient:Creating request http://httpstat.us/503
DEBUG:fedora.client.baseclient:Headers: {'Accept': 'application/json', 'User-agent': 'Fedora Bodhi Client/0.5.1'}
DEBUG:fedora.client.baseclient:Attempt #1 failed
DEBUG:fedora.client.baseclient:Attempt #2 failed
DEBUG:fedora.client.baseclient:Attempt #3 failed
---------------------------------------------------------------------------
ServerError                               Traceback (most recent call last)
<ipython-input-13-3d4c15b0c892> in <module>()
----> 1 b.send_request('503')

/home/kparal/devel/taskotron/env_taskotron/lib/python2.7/site-packages/fedora/client/baseclient.pyc in send_request(self, method, req_params, file_params, auth, retries, timeout, **kwargs)
    367         session_id, data = super(BaseClient, self).send_request(
    368             method, req_params=req_params, file_params=file_params,
--> 369             auth_params=auth_params, retries=retries, timeout=timeout)
    370         # In case the server returned a new session id to us
    371         if self.session_id != session_id:

/home/kparal/devel/taskotron/env_taskotron/lib/python2.7/site-packages/fedora/client/proxyclient.pyc in send_request(self, method, req_params, auth_params, file_params, retries, timeout)
    486                 except (KeyError, AttributeError):
    487                     msg = 'Unknown HTTP Server Response'
--> 488                 raise ServerError(url, http_status, msg)
    489             # Successfully returned data
    490             break

ServerError: ServerError(http://httpstat.us/503, 503, Service Unavailable)

Diff Detail

Repository
rLTRN libtaskotron
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kparal retitled this revision from to bodhi_utils: use internal retry logic.Jul 23 2015, 7:59 AM
kparal updated this object.
kparal edited the test plan for this revision. (Show Details)
kparal added reviewers: lbrabec, jskladan, tflink, mkrizek.
mkrizek accepted this revision.Jul 23 2015, 8:26 AM

LGTM

This revision is now accepted and ready to land.Jul 23 2015, 8:26 AM
kparal updated this revision to Diff 1241.Jul 23 2015, 8:31 AM
  • rebased
jskladan accepted this revision.Jul 23 2015, 8:45 AM
This revision was automatically updated to reflect the committed changes.