]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/rgw: move startup polling logic to util/rgw.py
authorCasey Bodley <cbodley@redhat.com>
Mon, 17 Apr 2017 19:39:37 +0000 (15:39 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 17 May 2017 18:48:55 +0000 (14:48 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
qa/tasks/rgw.py
qa/tasks/util/rgw.py

index 1e57045f7fc273527685bea11307d8e8420eafd9..cea5eb25408ef86e64bba033f67fbc6711450f12 100644 (file)
@@ -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
index 0cdb769b0aa2cda8e74862a511720c5cf180f9e6..bae8fdecd2f30d87774b6358b92998e400a0d293 100644 (file)
@@ -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)