From: Ali Maredia Date: Wed, 12 Jun 2019 20:12:47 +0000 (-0400) Subject: qa: use curl in wait_for_radosgw() in util/rgw.py X-Git-Tag: v12.2.13~209^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28669%2Fhead;p=ceph.git qa: use curl in wait_for_radosgw() in util/rgw.py Signed-off-by: Ali Maredia (cherry picked from commit 9c6afa3fb570629a57612f250a6a4890a65cbc6e) Conflicts: qa/tasks/rgw.py - rgw task was refactored for mimic --- diff --git a/qa/tasks/rgw.py b/qa/tasks/rgw.py index cec0b648bc7..e75f0712417 100644 --- a/qa/tasks/rgw.py +++ b/qa/tasks/rgw.py @@ -96,7 +96,8 @@ def start_rgw(ctx, config, clients): host, port = ctx.rgw.role_endpoints[client] endpoint = 'http://{host}:{port}/'.format(host=host, port=port) log.info('Polling {client} until it starts accepting connections on {endpoint}'.format(client=client, endpoint=endpoint)) - wait_for_radosgw(endpoint) + (remote,) = ctx.cluster.only(client).remotes.iterkeys() + wait_for_radosgw(endpoint, remote) try: yield diff --git a/qa/tasks/rgw_multisite.py b/qa/tasks/rgw_multisite.py index 668696b63b4..3026daf88cb 100644 --- a/qa/tasks/rgw_multisite.py +++ b/qa/tasks/rgw_multisite.py @@ -226,7 +226,7 @@ class Gateway(multisite.Gateway): """ (re)start the daemon """ self.daemon.restart() # wait until startup completes - wait_for_radosgw(self.endpoint()) + wait_for_radosgw(self.endpoint(), self.remote) def stop(self): """ stop the daemon """ diff --git a/qa/tasks/util/rgw.py b/qa/tasks/util/rgw.py index ab76b50a228..ee79208cc5b 100644 --- a/qa/tasks/util/rgw.py +++ b/qa/tasks/util/rgw.py @@ -2,6 +2,7 @@ from cStringIO import StringIO import logging import json import requests +import time from requests.packages.urllib3 import PoolManager from requests.packages.urllib3.util import Retry @@ -70,12 +71,29 @@ def get_user_successful_ops(out, user): return 0 return get_user_summary(out, user)['total']['successful_ops'] -def wait_for_radosgw(url): +def wait_for_radosgw(url, remote): """ poll the given url until it starts accepting connections add_daemon() doesn't wait until radosgw finishes startup, so this is used to avoid racing with later tasks that expect radosgw to be up and listening """ - # use a connection pool with retry/backoff to poll until it starts listening - http = PoolManager(retries=Retry(connect=8, backoff_factor=1)) - http.request('GET', url) + # TODO: use '--retry-connrefused --retry 8' when teuthology is running on + # Centos 8 and other OS's with an updated version of curl + curl_cmd = ['curl', + url] + exit_status = 0 + num_retries = 8 + for seconds in range(num_retries): + proc = remote.run( + args=curl_cmd, + check_status=False, + stdout=StringIO(), + stderr=StringIO(), + stdin=StringIO(), + ) + exit_status = proc.exitstatus + if exit_status == 0: + break + time.sleep(2**seconds) + + assert exit_status == 0