swift: make sure to retry if the client cannot find Swift
The following can happen:
2017-05-02 15:21:24.363 96139 CRITICAL gnocchi [-] ClientException: Endpoint for object-store not found - have you specified a region?
2017-05-02 15:21:24.363 96139 ERROR gnocchi Traceback (most recent call last):
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/bin/gnocchi-statsd", line 10, in <module>
2017-05-02 15:21:24.363 96139 ERROR gnocchi sys.exit(statsd())
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/gnocchi/cli.py", line 74, in statsd
2017-05-02 15:21:24.363 96139 ERROR gnocchi statsd_service.start()
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/gnocchi/statsd.py", line 174, in start
2017-05-02 15:21:24.363 96139 ERROR gnocchi stats = Stats(conf)
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/gnocchi/statsd.py", line 38, in __init__
2017-05-02 15:21:24.363 96139 ERROR gnocchi self.storage = storage.get_driver(self.conf)
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/gnocchi/storage/__init__.py", line 158, in get_driver
2017-05-02 15:21:24.363 96139 ERROR gnocchi return get_driver_class(conf)(conf.storage)
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/gnocchi/storage/swift.py", line 98, in __init__
2017-05-02 15:21:24.363 96139 ERROR gnocchi self.swift.put_container(self.MEASURE_PREFIX)
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 1728, in put_container
2017-05-02 15:21:24.363 96139 ERROR gnocchi query_string=query_string)
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 1635, in _retry
2017-05-02 15:21:24.363 96139 ERROR gnocchi self.url, self.token = self.get_auth()
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 1587, in get_auth
2017-05-02 15:21:24.363 96139 ERROR gnocchi timeout=self.timeout)
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 662, in get_auth
2017-05-02 15:21:24.363 96139 ERROR gnocchi auth_version=auth_version)
2017-05-02 15:21:24.363 96139 ERROR gnocchi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 596, in get_auth_keystone
2017-05-02 15:21:24.363 96139 ERROR gnocchi 'have you specified a region?' % service_type)
2017-05-02 15:21:24.363 96139 ERROR gnocchi ClientException: Endpoint for object-store not found - have you specified a region?
2017-05-02 15:21:24.363 96139 ERROR gnocchi
Make sure we retry.
Change-Id: I12ad167962aa62c22785c32394a607929ca8b925
(cherry picked from commit d81f13dc9f
)
This commit is contained in:
parent
44d2e7815a
commit
0f831a8ee6
|
@ -30,6 +30,7 @@ except ImportError:
|
|||
|
||||
from gnocchi import storage
|
||||
from gnocchi.storage import _carbonara
|
||||
from gnocchi import utils
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
@ -83,7 +84,13 @@ class SwiftStorage(_carbonara.CarbonaraBasedStorage):
|
|||
super(SwiftStorage, self).__init__(conf)
|
||||
if swclient is None:
|
||||
raise RuntimeError("python-swiftclient unavailable")
|
||||
self.swift = swclient.Connection(
|
||||
self.swift = self._get_connection(conf)
|
||||
self._container_prefix = conf.swift_container_prefix
|
||||
self.swift.put_container(self.MEASURE_PREFIX)
|
||||
|
||||
@utils.retry
|
||||
def _get_connection(self, conf):
|
||||
return swclient.Connection(
|
||||
auth_version=conf.swift_auth_version,
|
||||
authurl=conf.swift_authurl,
|
||||
preauthtoken=conf.swift_preauthtoken,
|
||||
|
@ -94,8 +101,6 @@ class SwiftStorage(_carbonara.CarbonaraBasedStorage):
|
|||
os_options={'endpoint_type': conf.swift_endpoint_type,
|
||||
'user_domain_name': conf.swift_user_domain_name},
|
||||
retries=0)
|
||||
self._container_prefix = conf.swift_container_prefix
|
||||
self.swift.put_container(self.MEASURE_PREFIX)
|
||||
|
||||
def _container_name(self, metric):
|
||||
return '%s.%s' % (self._container_prefix, str(metric.id))
|
||||
|
|
Loading…
Reference in New Issue