From 8795f591d541227cd704019f19f3a78c74fc8ac7 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Thu, 4 Apr 2019 14:13:16 -0400 Subject: [PATCH] Do not log a warning about not using compute monitors The compute_monitors configuration option is empty by default, however, on nova-compute startup we get a warning logged saying: Excluding nova.compute.monitors.cpu monitor virt_driver. \ Not in the list of enabled monitors (CONF.compute_monitors). This is unnecessary noise in the logs when nova-compute is not configured to use monitors, so this change avoids the warning log message in that case. The compute_monitors configuration option help text is also updated to (1) fix formatting and (2) remove the mention of the numa_mem_bw monitor which never made it into nova (see blueprint memory-bw). Change-Id: I5bd204e0017f6f795e3cf13b34b75124ee23aa78 Closes-Bug: #1823207 --- nova/compute/monitors/__init__.py | 10 ++++++---- nova/conf/compute.py | 6 +++--- nova/tests/unit/compute/monitors/test_monitors.py | 9 +++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/nova/compute/monitors/__init__.py b/nova/compute/monitors/__init__.py index f7cde9d7545c..26ac37a765d6 100644 --- a/nova/compute/monitors/__init__.py +++ b/nova/compute/monitors/__init__.py @@ -84,8 +84,10 @@ class MonitorHandler(object): if namespace + '.' + ext.name in cfg_monitors: self.type_monitor_loaded[namespace] = ext.name return True - LOG.warning("Excluding %(namespace)s monitor %(monitor_name)s. " - "Not in the list of enabled monitors " - "(CONF.compute_monitors).", - {'namespace': namespace, 'monitor_name': ext.name}) + # Only log something if compute_monitors is not empty. + if CONF.compute_monitors: + LOG.warning("Excluding %(namespace)s monitor %(monitor_name)s. " + "Not in the list of enabled monitors " + "(CONF.compute_monitors).", + {'namespace': namespace, 'monitor_name': ext.name}) return False diff --git a/nova/conf/compute.py b/nova/conf/compute.py index a7d68dea7372..95bc65294af6 100644 --- a/nova/conf/compute.py +++ b/nova/conf/compute.py @@ -113,10 +113,10 @@ a time. Possible values: * An empty list will disable the feature (Default). -* An example value that would enable both the CPU and NUMA memory - bandwidth monitors that use the virt driver variant: +* An example value that would enable the CPU + bandwidth monitor that uses the virt driver variant:: - compute_monitors = cpu.virt_driver, numa_mem_bw.virt_driver + compute_monitors = cpu.virt_driver """), cfg.StrOpt('default_ephemeral_format', help=""" diff --git a/nova/tests/unit/compute/monitors/test_monitors.py b/nova/tests/unit/compute/monitors/test_monitors.py index 963befe7b254..34b4a34d20b4 100644 --- a/nova/tests/unit/compute/monitors/test_monitors.py +++ b/nova/tests/unit/compute/monitors/test_monitors.py @@ -51,3 +51,12 @@ class MonitorsTestCase(test.NoDBTestCase): 'mon2') self.assertTrue(handler.check_enabled_monitor(ext_cpu_mon1)) self.assertFalse(handler.check_enabled_monitor(ext_cpu_mon2)) + + # Run the check but with no monitors enabled to make sure we don't log. + self.flags(compute_monitors=[]) + handler = monitors.MonitorHandler(None) + ext_cpu_mon1 = FakeExt('nova.compute.monitors.cpu.virt_driver:Monitor', + 'mon1') + with mock.patch.object(monitors.LOG, 'warning') as mock_warning: + self.assertFalse(handler.check_enabled_monitor(ext_cpu_mon1)) + mock_warning.assert_not_called()