Merge "Fix string interpolation to delay by logging"

This commit is contained in:
Zuul 2020-01-10 06:51:32 +00:00 committed by Gerrit Code Review
commit 2291fe673e
9 changed files with 24 additions and 25 deletions

View File

@ -117,8 +117,8 @@ def get_remaining_quota(context, db_api, image_id=None):
if not match:
LOG.error(_LE("Invalid value for option user_storage_quota: "
"%(users_quota)s")
% {'users_quota': users_quota})
"%(users_quota)s"),
{'users_quota': users_quota})
raise exception.InvalidOptionValue(option='user_storage_quota',
value=users_quota)
@ -166,8 +166,8 @@ def check_quota(context, image_size, db_api, image_id=None):
if remaining <= 0:
LOG.warn(_LW("User %(user)s attempted to upload an image of"
" unknown size that will exceed the quota."
" %(remaining)d bytes remaining.")
% {'user': user, 'remaining': remaining})
" %(remaining)d bytes remaining."),
{'user': user, 'remaining': remaining})
raise exception.StorageQuotaFull(image_size=image_size,
remaining=remaining)
return
@ -175,8 +175,8 @@ def check_quota(context, image_size, db_api, image_id=None):
if image_size > remaining:
LOG.warn(_LW("User %(user)s attempted to upload an image of size"
" %(size)d that will exceed the quota. %(remaining)d"
" bytes remaining.")
% {'user': user, 'size': image_size, 'remaining': remaining})
" bytes remaining."),
{'user': user, 'size': image_size, 'remaining': remaining})
raise exception.StorageQuotaFull(image_size=image_size,
remaining=remaining)

View File

@ -272,7 +272,7 @@ class CacheFilter(wsgi.Middleware):
try:
process_response_method = getattr(self, method_str)
except AttributeError:
LOG.error(_LE('could not find %s') % method_str)
LOG.error(_LE('could not find %s'), method_str)
# Nothing to do here, move along
return resp
else:

View File

@ -73,7 +73,7 @@ def safe_kill(req, image_id, from_state):
try:
_kill(req, image_id, from_state)
except Exception:
LOG.exception(_LE("Unable to kill image %(id)s: ") % {'id': image_id})
LOG.exception(_LE("Unable to kill image %(id)s: "), {'id': image_id})
def upload_data_to_store(req, image_meta, image_data, store, notifier):
@ -172,7 +172,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
# Delete image data due to possible token expiration.
LOG.debug("Authentication error - the token may have "
"expired during file upload. Deleting image data for "
" %s " % image_id)
" %s", image_id)
initiate_deletion(req, location_data, image_id)
raise webob.exc.HTTPUnauthorized(explanation=e.msg, request=req)
except exception.ImageNotFound:

View File

@ -82,7 +82,7 @@ def _load_strategies():
modules[strategy_name] = mgr.driver
except Exception as e:
LOG.error(_LE("Failed to load location strategy module "
"%(module)s: %(e)s") % {'module': module_name,
"%(module)s: %(e)s"), {'module': module_name,
'e': e})
return modules

View File

@ -430,7 +430,7 @@ def _image_get(context, image_id, force_show_deleted=False, status=None):
try:
image = DATA['images'][image_id]
except KeyError:
LOG.warn(_LW('Could not find image %s') % image_id)
LOG.warn(_LW('Could not find image %s'), image_id)
raise exception.ImageNotFound()
if image['deleted'] and not (force_show_deleted

View File

@ -46,7 +46,7 @@ class Prefetcher(base.CacheApp):
image_repo = self.gateway.get_repo(ctx)
image = image_repo.get(image_id)
except exception.NotFound:
LOG.warn(_LW("Image '%s' not found") % image_id)
LOG.warning(_LW("Image '%s' not found"), image_id)
return False
if image.status != 'active':

View File

@ -540,14 +540,13 @@ class ImageProxy(glance.domain.proxy.Image):
return data
except Exception as e:
LOG.warn(_LW('Get image %(id)s data failed: '
'%(err)s.')
% {'id': self.image.image_id,
'%(err)s.'),
{'id': self.image.image_id,
'err': encodeutils.exception_to_unicode(e)})
err = e
# tried all locations
LOG.error(_LE(
'Glance tried all active locations/stores to get data '
'for image %s but all have failed.') % self.image.image_id)
LOG.error(_LE('Glance tried all active locations to get data for '
'image %s but all have failed.'), self.image.image_id)
raise err

View File

@ -122,12 +122,12 @@ class Controller(object):
v1_mode=True, **params)
except exception.ImageNotFound:
LOG.warn(_LW("Invalid marker. Image %(id)s could not be "
"found.") % {'id': params.get('marker')})
"found."), {'id': params.get('marker')})
msg = _("Invalid marker. Image could not be found.")
raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden:
LOG.warn(_LW("Access denied to image %(id)s but returning "
"'not found'") % {'id': params.get('marker')})
"'not found'"), {'id': params.get('marker')})
msg = _("Invalid marker. Image could not be found.")
raise exc.HTTPBadRequest(explanation=msg)
except Exception:
@ -370,7 +370,7 @@ class Controller(object):
" 'not found'"), {'id': id})
raise exc.HTTPNotFound()
except Exception:
LOG.exception(_LE("Unable to show image %s") % id)
LOG.exception(_LE("Unable to show image %s"), id)
raise
return dict(image=make_image_dict(image))
@ -403,7 +403,7 @@ class Controller(object):
LOG.info(_LI("Image %(id)s not found"), {'id': id})
return exc.HTTPNotFound()
except Exception:
LOG.exception(_LE("Unable to delete image %s") % id)
LOG.exception(_LE("Unable to delete image %s"), id)
raise
@utils.mutating
@ -527,7 +527,7 @@ class Controller(object):
request=req,
content_type='text/plain')
except Exception:
LOG.exception(_LE("Unable to update image %s") % id)
LOG.exception(_LE("Unable to update image %s"), id)
raise

View File

@ -386,7 +386,7 @@ class Scrubber(object):
else:
LOG.warn(_LW("One or more image locations couldn't be scrubbed "
"from backend. Leaving image '%s' in 'pending_delete'"
" status") % image_id)
" status"), image_id)
def _delete_image_location_from_backend(self, image_id, loc_id, uri,
backend=None):