Enable H904 check

H904 allows the logging package to skip creating the formatted log
message if the message is not going to be emitted because of the
current log level.

Change-Id: Id6e27d8fefacd93bde41db21a20c8eaf3d3d6880
See: https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages
This commit is contained in:
Ngo Quoc Cuong 2017-07-06 03:59:23 -04:00
parent 93c8e006ce
commit b3506fa3eb
6 changed files with 22 additions and 19 deletions

View File

@ -284,8 +284,10 @@ class AmphoraAPIClient(object):
# amphora is not yet up, in which case retry.
# Otherwise return the response quickly.
if r.status_code == 404:
LOG.debug('Got a 404 (content-type: %s) -- connection '
'data: %s' % (content_type, r.content))
LOG.debug('Got a 404 (content-type: %(content_type)s) -- '
'connection data: %(content)s',
{'content_type': content_type,
'content': r.content})
if content_type.find("application/json") == -1:
LOG.debug("Amphora agent not ready.")
raise requests.ConnectionError

View File

@ -47,7 +47,7 @@ class SpareAmphora(object):
# When the current spare amphora is less than required
if diff_count > 0:
LOG.info("Initiating creation of %d spare amphora." % diff_count)
LOG.info("Initiating creation of %d spare amphora.", diff_count)
# Call Amphora Create Flow diff_count times
for i in range(1, diff_count + 1):
@ -81,7 +81,7 @@ class DatabaseCleanup(object):
self.amp_health_repo.delete(session, amphora_id=amp.id)
except sqlalchemy_exceptions.NoResultFound:
pass # Best effort delete, this record might not exist
LOG.info('Deleted Amphora id : %s' % amp.id)
LOG.info('Deleted Amphora id : %s', amp.id)
def cleanup_load_balancers(self):
"""Checks the DB for old load balancers and triggers their removal."""
@ -97,7 +97,7 @@ class DatabaseCleanup(object):
exp_age):
LOG.info('Attempting to delete load balancer id : %s', lb.id)
self.lb_repo.delete(session, id=lb.id)
LOG.info('Deleted load balancer id : %s' % lb.id)
LOG.info('Deleted load balancer id : %s', lb.id)
class CertRotation(object):
@ -120,5 +120,4 @@ class CertRotation(object):
LOG.debug("Cert expired amphora's id is: %s", amp.id)
executor.submit(self.cw.amphora_cert_rotation, amp.id)
if rotation_count > 0:
LOG.info("Rotated certificates for %s amphora" %
rotation_count)
LOG.info("Rotated certificates for %s amphora", rotation_count)

View File

@ -92,37 +92,37 @@ class Endpoint(object):
self.worker.delete_health_monitor(health_monitor_id)
def create_member(self, context, member_id):
LOG.info('Creating member \'%s\'...' % member_id)
LOG.info('Creating member \'%s\'...', member_id)
self.worker.create_member(member_id)
def update_member(self, context, member_id, member_updates):
LOG.info('Updating member \'%s\'...' % member_id)
LOG.info('Updating member \'%s\'...', member_id)
self.worker.update_member(member_id, member_updates)
def delete_member(self, context, member_id):
LOG.info('Deleting member \'%s\'...' % member_id)
LOG.info('Deleting member \'%s\'...', member_id)
self.worker.delete_member(member_id)
def create_l7policy(self, context, l7policy_id):
LOG.info('Creating l7policy \'%s\'...' % l7policy_id)
LOG.info('Creating l7policy \'%s\'...', l7policy_id)
self.worker.create_l7policy(l7policy_id)
def update_l7policy(self, context, l7policy_id, l7policy_updates):
LOG.info('Updating l7policy \'%s\'...' % l7policy_id)
LOG.info('Updating l7policy \'%s\'...', l7policy_id)
self.worker.update_l7policy(l7policy_id, l7policy_updates)
def delete_l7policy(self, context, l7policy_id):
LOG.info('Deleting l7policy \'%s\'...' % l7policy_id)
LOG.info('Deleting l7policy \'%s\'...', l7policy_id)
self.worker.delete_l7policy(l7policy_id)
def create_l7rule(self, context, l7rule_id):
LOG.info('Creating l7rule \'%s\'...' % l7rule_id)
LOG.info('Creating l7rule \'%s\'...', l7rule_id)
self.worker.create_l7rule(l7rule_id)
def update_l7rule(self, context, l7rule_id, l7rule_updates):
LOG.info('Updating l7rule \'%s\'...' % l7rule_id)
LOG.info('Updating l7rule \'%s\'...', l7rule_id)
self.worker.update_l7rule(l7rule_id, l7rule_updates)
def delete_l7rule(self, context, l7rule_id):
LOG.info('Deleting l7rule \'%s\'...' % l7rule_id)
LOG.info('Deleting l7rule \'%s\'...', l7rule_id)
self.worker.delete_l7rule(l7rule_id)

View File

@ -651,7 +651,7 @@ class ControllerWorker(base_taskflow.BaseTaskFlowEngine):
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.error("Failover exception: %s" % e)
LOG.error("Failover exception: %s", e)
def amphora_cert_rotation(self, amphora_id):
"""Perform cert rotation for an amphora.
@ -663,7 +663,7 @@ class ControllerWorker(base_taskflow.BaseTaskFlowEngine):
amp = self._amphora_repo.get(db_apis.get_session(),
id=amphora_id)
LOG.info("Start amphora cert rotation, amphora's id is: %s" % amp.id)
LOG.info("Start amphora cert rotation, amphora's id is: %s", amp.id)
certrotation_amphora_tf = self._taskflow_load(
self._amphora_flows.cert_rotate_amphora_flow(),

View File

@ -500,7 +500,7 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
raise base.PlugNetworkException(e.message)
except nova_client_exceptions.Conflict:
LOG.info('Port %(portid)s is already plugged, '
'skipping' % {'portid': port.id})
'skipping', {'portid': port.id})
plugged_interface = n_data_models.Interface(
compute_id=amphora.compute_id,
network_id=port.network_id,

View File

@ -116,6 +116,8 @@ ignore =
show-source = true
builtins = _
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build
# [H904] Delay string interpolations at logging calls.
enable-extensions=H904
[hacking]
import_exceptions = octavia.i18n