Skip to content

Commit

Permalink
qa: use curl in wait_for_radosgw() in util/rgw.py
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Maredia <amaredia@redhat.com>
(cherry picked from commit 9c6afa3)
  • Loading branch information
alimaredia authored and cbodley committed Jun 17, 2019
1 parent 100196f commit a4fe5f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
3 changes: 2 additions & 1 deletion qa/tasks/rgw.py
Expand Up @@ -140,7 +140,8 @@ def start_rgw(ctx, config, clients):
endpoint = ctx.rgw.role_endpoints[client]
url = endpoint.url()
log.info('Polling {client} until it starts accepting connections on {url}'.format(client=client, url=url))
wait_for_radosgw(url)
(remote,) = ctx.cluster.only(client).remotes.iterkeys()
wait_for_radosgw(url, remote)

try:
yield
Expand Down
2 changes: 1 addition & 1 deletion qa/tasks/rgw_multisite.py
Expand Up @@ -226,7 +226,7 @@ def start(self, args = None):
""" (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 """
Expand Down
26 changes: 22 additions & 4 deletions qa/tasks/util/rgw.py
Expand Up @@ -2,6 +2,7 @@
import logging
import json
import requests
import time

from requests.packages.urllib3 import PoolManager
from requests.packages.urllib3.util import Retry
Expand Down Expand Up @@ -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

0 comments on commit a4fe5f3

Please sign in to comment.