Merge "Swallow & report 404s from Swift (missing tenant)" into stable/newton

This commit is contained in:
Jenkins 2017-04-11 20:44:36 +00:00 committed by Gerrit Code Review
commit 16afa59c58
1 changed files with 16 additions and 9 deletions

View File

@ -22,6 +22,7 @@ from oslo_config import cfg
from oslo_log import log
import six.moves.urllib.parse as urlparse
from swiftclient import client as swift
from swiftclient.exceptions import ClientException
from ceilometer.agent import plugin_base
from ceilometer.i18n import _LI
@ -89,11 +90,17 @@ class _Base(plugin_base.PollsterBase):
if not endpoint:
raise StopIteration()
swift_api_method = getattr(swift, '%s_account' % self.METHOD)
for t in tenants:
api_method = '%s_account' % self.METHOD
yield (t.id, getattr(swift, api_method)
(self._neaten_url(endpoint, t.id),
keystone_client.get_auth_token(ksclient)))
try:
yield (t.id, swift_api_method(
self._neaten_url(endpoint, t.id),
keystone_client.get_auth_token(ksclient)))
except ClientException as e:
if e.http_status == 404:
LOG.warning("Swift tenant id %s not found.", t.id)
else:
raise e
@staticmethod
def _neaten_url(endpoint, tenant_id):
@ -103,7 +110,7 @@ class _Base(plugin_base.PollsterBase):
class ObjectsPollster(_Base):
"""Collect the total objects count for each project."""
"""Collect the total objects count for each project"""
def get_samples(self, manager, cache, resources):
tenants = resources
for tenant, account in self._iter_accounts(manager.keystone,
@ -121,7 +128,7 @@ class ObjectsPollster(_Base):
class ObjectsSizePollster(_Base):
"""Collect the total objects size of each project."""
"""Collect the total objects size of each project"""
def get_samples(self, manager, cache, resources):
tenants = resources
for tenant, account in self._iter_accounts(manager.keystone,
@ -139,7 +146,7 @@ class ObjectsSizePollster(_Base):
class ObjectsContainersPollster(_Base):
"""Collect the container count for each project."""
"""Collect the container count for each project"""
def get_samples(self, manager, cache, resources):
tenants = resources
for tenant, account in self._iter_accounts(manager.keystone,
@ -157,7 +164,7 @@ class ObjectsContainersPollster(_Base):
class ContainersObjectsPollster(_Base):
"""Collect the objects count per container for each project."""
"""Collect the objects count per container for each project"""
METHOD = 'get'
@ -180,7 +187,7 @@ class ContainersObjectsPollster(_Base):
class ContainersSizePollster(_Base):
"""Collect the total objects size per container for each project."""
"""Collect the total objects size per container for each project"""
METHOD = 'get'