diff options
author | Nick Vatamaniuc <vatamane@gmail.com> | 2015-10-07 00:35:02 -0400 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2015-10-07 10:26:57 +0100 |
commit | 9e2010afe60695af03be75f0e8e5ec57ac684842 (patch) | |
tree | 05f6cd8380412d10dde717567013e9e4660040b3 /dev | |
parent | 093eafd90059b948050d901b0f227bf964c724ce (diff) | |
download | couchdb-9e2010afe60695af03be75f0e8e5ec57ac684842.tar.gz |
Retry database creation during cluster setup
Diffstat (limited to 'dev')
-rwxr-xr-x | dev/run | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -476,16 +476,24 @@ def cluster_setup_with_admin_party(ctx): create_system_databases(host, 15984) +def try_request(host, port, meth, path, success_codes, retries=10, retry_dt=1): + while True: + conn = httpclient.HTTPConnection(host, port) + conn.request(meth, path) + resp = conn.getresponse() + if resp.status in success_codes or retries == 0: + return resp.status, resp.read() + retries -= 1 + time.sleep(retry_dt) + + def create_system_databases(host, port): for dbname in ['_users', '_replicator', '_metadata', '_global_changes']: conn = httpclient.HTTPConnection(host, port) conn.request('HEAD', '/' + dbname) resp = conn.getresponse() if resp.status == 404: - conn = httpclient.HTTPConnection(host, port) - conn.request('PUT', '/' + dbname) - resp = conn.getresponse() - assert resp.status in (201, 202), resp.read() + try_request(host, port, 'PUT', '/' + dbname, (201, 202, 412)) @log('Developers cluster is set up at http://127.0.0.1:{lead_port}.\n' |