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