Commit 5ada78fb authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review

Merge "Adjust log levels for InstanceShutOffException"

parents 9fab213b 710b92c4
......@@ -20,7 +20,7 @@ import ceilometer
from ceilometer.compute import pollsters
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.i18n import _, _LW
from ceilometer.i18n import _
from ceilometer import sample
LOG = log.getLogger(__name__)
......@@ -49,10 +49,10 @@ class CPUPollster(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.debug('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s',
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('Obtaining CPU time is not implemented for %s',
......
......@@ -24,7 +24,7 @@ import ceilometer
from ceilometer.compute import pollsters
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.i18n import _, _LW
from ceilometer.i18n import _
from ceilometer import sample
LOG = log.getLogger(__name__)
......@@ -160,10 +160,10 @@ class _Base(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.debug('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s',
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('%(inspector)s does not provide data for '
......@@ -630,10 +630,10 @@ class _DiskInfoPollsterBase(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.debug('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s',
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('%(inspector)s does not provide data for '
......
......@@ -48,10 +48,10 @@ class MemoryUsagePollster(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.debug('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s',
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except virt_inspector.NoDataException as e:
LOG.warning(_LW('Cannot inspect data of %(pollster)s for '
'%(instance_id)s, non-fatal reason: %(exc)s'),
......@@ -91,10 +91,10 @@ class MemoryResidentPollster(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.debug('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s',
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except virt_inspector.NoDataException as e:
LOG.warning(_LW('Cannot inspect data of %(pollster)s for '
'%(instance_id)s, non-fatal reason: %(exc)s'),
......
......@@ -22,7 +22,7 @@ import ceilometer
from ceilometer.compute import pollsters
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.i18n import _, _LW
from ceilometer.i18n import _
from ceilometer import sample
LOG = log.getLogger(__name__)
......@@ -96,10 +96,10 @@ class _Base(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.debug('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s',
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('%(inspector)s does not provide data for '
......
......@@ -49,7 +49,8 @@ class TestMemoryPollster(base.TestPollsterBase):
pollster = memory.MemoryUsagePollster()
@mock.patch('ceilometer.compute.pollsters.memory.LOG')
def _verify_memory_metering(expected_count, expected_memory_mb, mylog):
def _verify_memory_metering(expected_count, expected_memory_mb,
expected_warnings, mylog):
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual(expected_count, len(samples))
if expected_count > 0:
......@@ -57,13 +58,13 @@ class TestMemoryPollster(base.TestPollsterBase):
set([s.name for s in samples]))
self.assertEqual(expected_memory_mb, samples[0].volume)
else:
self.assertEqual(1, mylog.warning.call_count)
self.assertEqual(expected_warnings, mylog.warning.call_count)
self.assertEqual(0, mylog.exception.call_count)
_verify_memory_metering(1, 1.0)
_verify_memory_metering(1, 2.0)
_verify_memory_metering(0, 0)
_verify_memory_metering(0, 0)
_verify_memory_metering(1, 1.0, 0)
_verify_memory_metering(1, 2.0, 0)
_verify_memory_metering(0, 0, 1)
_verify_memory_metering(0, 0, 0)
class TestResidentMemoryPollster(base.TestPollsterBase):
......@@ -96,7 +97,7 @@ class TestResidentMemoryPollster(base.TestPollsterBase):
@mock.patch('ceilometer.compute.pollsters.memory.LOG')
def _verify_resident_memory_metering(expected_count,
expected_resident_memory_mb,
mylog):
expected_warnings, mylog):
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual(expected_count, len(samples))
if expected_count > 0:
......@@ -105,10 +106,10 @@ class TestResidentMemoryPollster(base.TestPollsterBase):
self.assertEqual(expected_resident_memory_mb,
samples[0].volume)
else:
self.assertEqual(1, mylog.warning.call_count)
self.assertEqual(expected_warnings, mylog.warning.call_count)
self.assertEqual(0, mylog.exception.call_count)
_verify_resident_memory_metering(1, 1.0)
_verify_resident_memory_metering(1, 2.0)
_verify_resident_memory_metering(0, 0)
_verify_resident_memory_metering(0, 0)
_verify_resident_memory_metering(1, 1.0, 0)
_verify_resident_memory_metering(1, 2.0, 0)
_verify_resident_memory_metering(0, 0, 1)
_verify_resident_memory_metering(0, 0, 0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment