From 746c630999f342810850876903d8cb94388ca081 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 17 Apr 2017 15:39:37 -0400 Subject: [PATCH] qa/rgw: move startup polling logic to util/rgw.py Signed-off-by: Casey Bodley --- qa/tasks/rgw.py | 9 ++------- qa/tasks/util/rgw.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/qa/tasks/rgw.py b/qa/tasks/rgw.py index 1e57045f7fc27..cea5eb25408ef 100644 --- a/qa/tasks/rgw.py +++ b/qa/tasks/rgw.py @@ -9,16 +9,13 @@ import os import errno import util.rgw as rgw_utils -from requests.packages.urllib3 import PoolManager -from requests.packages.urllib3.util import Retry - from cStringIO import StringIO from teuthology.orchestra import run from teuthology import misc as teuthology from teuthology import contextutil from teuthology.orchestra.run import CommandFailedError -from util.rgw import rgwadmin, get_config_master_client, extract_zone_info, extract_region_info +from util.rgw import rgwadmin, get_config_master_client, extract_zone_info, extract_region_info, wait_for_radosgw from util.rados import (rados, create_ec_pool, create_replicated_pool, create_cache_pool) @@ -345,15 +342,13 @@ def start_rgw(ctx, config, on_client = None, except_client = None): ) # XXX: add_daemon() doesn't let us wait until radosgw finishes startup - # use a connection pool with retry/backoff to poll each gateway until it starts listening - http = PoolManager(retries=Retry(connect=8, backoff_factor=1)) for client in clients_to_run: if client == except_client: continue 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)) - http.request('GET', endpoint) + wait_for_radosgw(endpoint) try: yield diff --git a/qa/tasks/util/rgw.py b/qa/tasks/util/rgw.py index 0cdb769b0aa2c..bae8fdecd2f30 100644 --- a/qa/tasks/util/rgw.py +++ b/qa/tasks/util/rgw.py @@ -2,6 +2,8 @@ from cStringIO import StringIO import logging import json import requests + +from requests.packages.urllib3 import PoolManager from requests.packages.urllib3.util import Retry from urlparse import urlparse @@ -302,3 +304,12 @@ def get_config_master_client(ctx, config, regions): return None +def wait_for_radosgw(url): + """ 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) -- 2.39.5