Merge "Use olso_log and delay string interpolation while logging"
This commit is contained in:
commit
5e99a99c6a
@ -14,13 +14,13 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
import glance_store as store_api
|
||||
from glance_store import backend
|
||||
from oslo_concurrency import processutils as putils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import excutils
|
||||
import six
|
||||
@ -158,10 +158,9 @@ class _ImportToFS(task.Task):
|
||||
except OSError as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
exc_message = encodeutils.exception_to_unicode(exc)
|
||||
msg = (_LE('Failed to execute security checks on the image '
|
||||
'%(task_id)s: %(exc)s') %
|
||||
{'task_id': self.task_id, 'exc': exc_message})
|
||||
LOG.error(msg)
|
||||
msg = _LE('Failed to execute security checks on the image '
|
||||
'%(task_id)s: %(exc)s')
|
||||
LOG.error(msg, {'task_id': self.task_id, 'exc': exc_message})
|
||||
|
||||
metadata = json.loads(stdout)
|
||||
|
||||
@ -177,7 +176,7 @@ class _ImportToFS(task.Task):
|
||||
def revert(self, image_id, result, **kwargs):
|
||||
if isinstance(result, failure.Failure):
|
||||
LOG.exception(_LE('Task: %(task_id)s failed to import image '
|
||||
'%(image_id)s to the filesystem.') %
|
||||
'%(image_id)s to the filesystem.'),
|
||||
{'task_id': self.task_id, 'image_id': image_id})
|
||||
return
|
||||
|
||||
@ -363,12 +362,15 @@ class _CompleteTask(task.Task):
|
||||
|
||||
# TODO(nikhil): need to bring back save_and_reraise_exception when
|
||||
# necessary
|
||||
err_msg = ("Error: " + six.text_type(type(e)) + ': ' +
|
||||
encodeutils.exception_to_unicode(e))
|
||||
log_msg = err_msg + _LE("Task ID %s") % task.task_id
|
||||
LOG.exception(log_msg)
|
||||
log_msg = _LE("Task ID %(task_id)s failed. Error: %(exc_type)s: "
|
||||
"%(e)s")
|
||||
LOG.exception(log_msg, {'exc_type': six.text_type(type(e)),
|
||||
'e': encodeutils.exception_to_unicode(e),
|
||||
'task_id': task.task_id})
|
||||
|
||||
task.fail(err_msg)
|
||||
err_msg = _("Error: %(exc_type)s: %(e)s")
|
||||
task.fail(err_msg % {'exc_type': six.text_type(type(e)),
|
||||
'e': encodeutils.exception_to_unicode(e)})
|
||||
finally:
|
||||
self.task_repo.save(task)
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from taskflow.patterns import linear_flow as lf
|
||||
from taskflow import task
|
||||
|
||||
@ -61,11 +61,10 @@ class _Convert(task.Task):
|
||||
conversion_format = CONF.taskflow_executor.conversion_format
|
||||
if conversion_format is None:
|
||||
if not _Convert.conversion_missing_warned:
|
||||
msg = (_LW('The conversion format is None, please add a value '
|
||||
'for it in the config file for this task to '
|
||||
'work: %s') %
|
||||
self.task_id)
|
||||
LOG.warn(msg)
|
||||
msg = _LW('The conversion format is None, please add a value '
|
||||
'for it in the config file for this task to '
|
||||
'work: %s')
|
||||
LOG.warn(msg, self.task_id)
|
||||
_Convert.conversion_missing_warned = True
|
||||
return
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import excutils
|
||||
from taskflow.patterns import linear_flow as lf
|
||||
@ -57,10 +57,10 @@ class _Introspect(utils.OptionalTask):
|
||||
if exc.errno != 2:
|
||||
with excutils.save_and_reraise_exception():
|
||||
exc_message = encodeutils.exception_to_unicode(exc)
|
||||
msg = (_LE('Failed to execute introspection '
|
||||
'%(task_id)s: %(exc)s') %
|
||||
{'task_id': self.task_id, 'exc': exc_message})
|
||||
LOG.error(msg)
|
||||
msg = _LE('Failed to execute introspection '
|
||||
'%(task_id)s: %(exc)s')
|
||||
LOG.error(msg, {'task_id': self.task_id,
|
||||
'exc': exc_message})
|
||||
return
|
||||
|
||||
if stderr:
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
@ -25,6 +24,7 @@ except ImportError:
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils as json
|
||||
from six.moves import urllib
|
||||
from taskflow.patterns import linear_flow as lf
|
||||
|
Loading…
Reference in New Issue
Block a user