From 818c31f96e773a47a6fcbf084e13933865fdac80 Mon Sep 17 00:00:00 2001 From: melanie witt Date: Mon, 17 Jun 2019 21:21:27 +0000 Subject: [PATCH] Log quota legacy method warning only if counting from placement The log warning message is being emitted unconditionally and should be limited to only when CONF.quota.count_usage_from_placement = True. This fixes the issue and adds missing unit test coverage that would have caught it. Closes-Bug: #1833130 Change-Id: I00ee0bd99c4f31a2b73fc69373fefb56740f5425 --- nova/quota.py | 4 ++-- nova/tests/unit/test_quota.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/quota.py b/nova/quota.py index 8fe142e2d5d7..241d7ecc0810 100644 --- a/nova/quota.py +++ b/nova/quota.py @@ -1312,8 +1312,8 @@ def _instances_cores_ram_count(context, project_id, user_id=None): return _instances_cores_ram_count_api_db_placement(context, project_id, user_id=user_id) - LOG.warning('Falling back to legacy quota counting method for instances, ' - 'cores, and ram') + LOG.warning('Falling back to legacy quota counting method for ' + 'instances, cores, and ram') return _instances_cores_ram_count_legacy(context, project_id, user_id=user_id) diff --git a/nova/tests/unit/test_quota.py b/nova/tests/unit/test_quota.py index 85d37be3300c..e178f0c39aea 100644 --- a/nova/tests/unit/test_quota.py +++ b/nova/tests/unit/test_quota.py @@ -2057,6 +2057,8 @@ class QuotaCountTestCase(test.NoDBTestCase): # We only log the message if someone has opted in to counting # from placement. mock_warn_log.assert_called_once() + else: + mock_warn_log.assert_not_called() # We should not have called the API DB and placement counting # method. mock_api_db_placement_count.assert_not_called()