From 030df4e31005e28b71f549dbb888f3040e0a4457 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Mon, 5 Nov 2018 16:20:30 +0200 Subject: [PATCH] Disable wmi object caching by default Due to the known issues related to WMI object caching, it's safer if we just disable it by default. Change-Id: If859917af9a185fc612231002d252c9e0ac6ddd3 Related-Bug: #1801701 --- os_win/conf.py | 6 ++++-- os_win/tests/unit/utils/network/test_networkutils.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/os_win/conf.py b/os_win/conf.py index 96691ad5..44d6e563 100644 --- a/os_win/conf.py +++ b/os_win/conf.py @@ -23,12 +23,14 @@ os_win_opts = [ help='Fibre Channel hbaapi library path. If no custom hbaapi ' 'library is requested, the default one will be used.'), cfg.BoolOpt('cache_temporary_wmi_objects', - default=True, + default=False, help='Caches temporary WMI objects in order to increase ' 'performance. This only affects networkutils, where ' 'almost all operations require a reference to a ' 'switch port. The cached objects are no longer valid ' - 'if the VM they are associated with is destroyed.'), + 'if the VM they are associated with is destroyed. ' + 'WARNING: use with caution, the cache may become ' + 'invalid when certain resources are recreated.'), cfg.IntOpt('wmi_job_terminate_timeout', default=120, help='The default amount of seconds to wait when stopping ' diff --git a/os_win/tests/unit/utils/network/test_networkutils.py b/os_win/tests/unit/utils/network/test_networkutils.py index be2b7cdd..6a75389b 100644 --- a/os_win/tests/unit/utils/network/test_networkutils.py +++ b/os_win/tests/unit/utils/network/test_networkutils.py @@ -72,6 +72,8 @@ class NetworkUtilsTestCase(test_base.OsWinBaseTestCase): self.assertEqual({}, self.netutils._switches) def test_init_caches(self): + self.netutils._enable_cache = True + self.netutils._switches = {} self.netutils._switch_ports = {} self.netutils._vlan_sds = {} @@ -125,6 +127,8 @@ class NetworkUtilsTestCase(test_base.OsWinBaseTestCase): self.assertEqual({}, self.netutils._switch_ports) def test_update_cache(self): + self.netutils._enable_cache = True + self.netutils._switch_ports[mock.sentinel.other] = mock.sentinel.port conn = self.netutils._conn mock_port = mock.MagicMock(ElementName=mock.sentinel.port_name)