Merge "Cleaning up logging"

This commit is contained in:
Zuul 2019-02-08 18:57:58 +00:00 committed by Gerrit Code Review
commit d21c99fba9
4 changed files with 36 additions and 35 deletions

View File

@ -72,8 +72,8 @@ class SkippingAuthProtocol(auth_token.AuthProtocol):
def process_request(self, request): def process_request(self, request):
path = request.path path = request.path
if path in _NOAUTH_PATHS: if path in _NOAUTH_PATHS:
LOG.debug(('Request path is %s and it does not require keystone ' LOG.debug('Request path is %s and it does not require keystone '
'authentication'), path) 'authentication', path)
return None # return NONE to reach actual logic return None # return NONE to reach actual logic
return super(SkippingAuthProtocol, self).process_request(request) return super(SkippingAuthProtocol, self).process_request(request)

View File

@ -104,8 +104,8 @@ class exception_logger(object):
def __call__(self, func): def __call__(self, func):
if self.logger is None: if self.logger is None:
LOG = logging.getLogger(func.__module__) _LOG = logging.getLogger(func.__module__)
self.logger = LOG.exception self.logger = _LOG.exception
def call(*args, **kwargs): def call(*args, **kwargs):
try: try:

View File

@ -24,7 +24,6 @@ from octavia.common import constants
from octavia.common import data_models as models from octavia.common import data_models as models
from octavia.common import exceptions from octavia.common import exceptions
from octavia.compute import compute_base from octavia.compute import compute_base
from octavia.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -302,14 +301,15 @@ class VirtualMachineManager(compute_base.ComputeBase):
server=compute_id, net_id=network_id, fixed_ip=ip_address, server=compute_id, net_id=network_id, fixed_ip=ip_address,
port_id=port_id) port_id=port_id)
except Exception: except Exception:
message = _('Error attaching network {network_id} with ip ' LOG.error('Error attaching network %(network_id)s with ip '
'{ip_address} and port {port} to amphora ' '%(ip_address)s and port %(port)s to amphora '
'(compute_id: {compute_id}) ').format( '(compute_id: %(compute_id)s) ',
compute_id=compute_id, {
network_id=network_id, 'compute_id': compute_id,
ip_address=ip_address, 'network_id': network_id,
port=port_id) 'ip_address': ip_address,
LOG.error(message) 'port': port_id
})
raise raise
return interface return interface
@ -324,10 +324,13 @@ class VirtualMachineManager(compute_base.ComputeBase):
self.manager.interface_detach(server=compute_id, self.manager.interface_detach(server=compute_id,
port_id=port_id) port_id=port_id)
except Exception: except Exception:
LOG.error('Error detaching port {port_id} from amphora ' LOG.error('Error detaching port %(port_id)s from amphora '
'with compute ID {compute_id}. ' 'with compute ID %(compute_id)s. '
'Skipping.'.format(port_id=port_id, 'Skipping.',
compute_id=compute_id)) {
'port_id': port_id,
'compute_id': compute_id
})
def validate_flavor(self, flavor_id): def validate_flavor(self, flavor_id):
"""Validates that a flavor exists in nova. """Validates that a flavor exists in nova.
@ -339,10 +342,10 @@ class VirtualMachineManager(compute_base.ComputeBase):
try: try:
self.flavor_manager.get(flavor_id) self.flavor_manager.get(flavor_id)
except nova_exceptions.NotFound: except nova_exceptions.NotFound:
LOG.info('Flavor {} was not found in nova.'.format(flavor_id)) LOG.info('Flavor %s was not found in nova.', flavor_id)
raise exceptions.InvalidSubresource(resource='Nova flavor', raise exceptions.InvalidSubresource(resource='Nova flavor',
id=flavor_id) id=flavor_id)
except Exception as e: except Exception as e:
LOG.exception('Nova reports a failure getting flavor details for ' LOG.exception('Nova reports a failure getting flavor details for '
'flavor ID {0}: {1}'.format(flavor_id, str(e))) 'flavor ID %s: %s', flavor_id, e)
raise raise

View File

@ -87,10 +87,10 @@ class UpdateHealthDb(update_base.HealthUpdateBase):
except Exception as e: except Exception as e:
LOG.exception('Health update for amphora %(amp)s encountered ' LOG.exception('Health update for amphora %(amp)s encountered '
'error %(err)s. Skipping health update.', 'error %(err)s. Skipping health update.',
{'amp': health['id'], 'err': str(e)}) {'amp': health['id'], 'err': e})
# TODO(johnsom) We need to set a warning threshold here # TODO(johnsom) We need to set a warning threshold here
LOG.debug('Health Update finished in: {0} seconds'.format( LOG.debug('Health Update finished in: %s seconds',
timeit.default_timer() - start_time)) timeit.default_timer() - start_time)
# Health heartbeat messsage pre-versioning with UDP listeners # Health heartbeat messsage pre-versioning with UDP listeners
# need to adjust the expected listener count # need to adjust the expected listener count
@ -173,18 +173,17 @@ class UpdateHealthDb(update_base.HealthUpdateBase):
if not amp or amp.load_balancer_id: if not amp or amp.load_balancer_id:
# This is debug and not warning because this can happen under # This is debug and not warning because this can happen under
# normal deleting operations. # normal deleting operations.
LOG.debug('Received a health heartbeat from amphora {0} with ' LOG.debug('Received a health heartbeat from amphora %s with '
'IP {1} that should not exist. This amphora may be ' 'IP %s that should not exist. This amphora may be '
'in the process of being deleted, in which case you ' 'in the process of being deleted, in which case you '
'will only see this message a few ' 'will only see this message a few '
'times'.format(health['id'], srcaddr)) 'times', health['id'], srcaddr)
if not amp: if not amp:
LOG.warning('The amphora {0} with IP {1} is missing from ' LOG.warning('The amphora %s with IP %s is missing from '
'the DB, so it cannot be automatically ' 'the DB, so it cannot be automatically '
'deleted (the compute_id is unknown). An ' 'deleted (the compute_id is unknown). An '
'operator must manually delete it from the ' 'operator must manually delete it from the '
'compute service.'.format(health['id'], 'compute service.', health['id'], srcaddr)
srcaddr))
return return
# delete the amp right there # delete the amp right there
try: try:
@ -196,8 +195,8 @@ class UpdateHealthDb(update_base.HealthUpdateBase):
compute.delete(amp.compute_id) compute.delete(amp.compute_id)
return return
except Exception as e: except Exception as e:
LOG.info("Error deleting amp {0} with IP {1}".format( LOG.info("Error deleting amp %s with IP %s Error: %s",
health['id'], srcaddr), e) health['id'], srcaddr, e)
expected_listener_count = 0 expected_listener_count = 0
listeners = health['listeners'] listeners = health['listeners']
@ -434,8 +433,8 @@ class UpdateStatsDb(update_base.StatsUpdateBase, stats.StatsMixin):
self._update_stats(health_message, srcaddr) self._update_stats(health_message, srcaddr)
except Exception: except Exception:
LOG.exception('update_stats encountered an unknown error ' LOG.exception('update_stats encountered an unknown error '
'processing stats for amphora {0} with IP ' 'processing stats for amphora %s with IP '
'{1}'.format(health_message['id'], srcaddr)) '%s', health_message['id'], srcaddr)
def _update_stats(self, health_message, srcaddr): def _update_stats(self, health_message, srcaddr):
"""This function is to update the db with listener stats """This function is to update the db with listener stats
@ -495,9 +494,8 @@ class UpdateStatsDb(update_base.StatsUpdateBase, stats.StatsMixin):
listener_db = self.repo_listener.get(session, id=listener_id) listener_db = self.repo_listener.get(session, id=listener_id)
if not listener_db: if not listener_db:
LOG.debug('Received health stats for a non-existent ' LOG.debug('Received health stats for a non-existent '
'listener {0} for amphora {1} with IP ' 'listener %s for amphora %s with IP '
'{2}.'.format(listener_id, amphora_id, '%s.', listener_id, amphora_id, srcaddr)
srcaddr))
return return
lb_stats = self.get_loadbalancer_stats( lb_stats = self.get_loadbalancer_stats(