summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2016-09-27 10:08:23 -0500
committerTony Asleson <tasleson@redhat.com>2016-09-27 13:28:54 -0500
commita93616cf66b15591f741dc5f1450c12bc34b3785 (patch)
tree7dc607e99a4a66257baadf4990f8713fde8bbcb1
parentd906fd520129d639c7cad27c24f88836d133f9ad (diff)
downloadlvm2-a93616cf66b15591f741dc5f1450c12bc34b3785.tar.gz
lvmdbusd: Add diagnostic validate for look ups
Make sure that the lookup tables don't have extranoues stuff in them.
-rw-r--r--daemons/lvmdbusd/manager.py6
-rw-r--r--daemons/lvmdbusd/objectmanager.py28
2 files changed, 32 insertions, 2 deletions
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index b7d7b106a..0a5fe730f 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -115,6 +115,10 @@ class Manager(AutomatedProperties):
# This is a diagnostic and should not be run in normal operation, so
# lets remove the log entries for refresh as it's implied.
+
+ # Run an internal diagnostic on the object manager look up tables
+ lc = cfg.om.validate_lookups()
+
rc = cfg.load(log=False)
if rc != 0:
@@ -122,7 +126,7 @@ class Manager(AutomatedProperties):
'bg_black', 'fg_light_red')
else:
utils.log_debug('Manager.Refresh - exit %d' % (rc))
- return rc
+ return rc + lc
@dbus.service.method(
dbus_interface=MANAGER_INTERFACE,
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index f491df49e..d55ca9982 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -12,8 +12,9 @@ import threading
import traceback
import dbus
import os
+import copy
from . import cfg
-from .utils import log_debug, pv_obj_path_generate
+from .utils import log_debug, pv_obj_path_generate, log_error
from .automatedproperties import AutomatedProperties
@@ -70,6 +71,31 @@ class ObjectManager(AutomatedProperties):
log_debug(('SIGNAL: InterfacesRemoved(%s, %s)' %
(str(object_path), str(interface_list))))
+ def validate_lookups(self):
+ with self.rlock:
+ tmp_lookups = copy.deepcopy(self._id_to_object_path)
+
+ # iterate over all we know, removing from the copy. If all is well
+ # we will have zero items left over
+ for path, md in self._objects.items():
+ obj, lvm_id, uuid = md
+
+ if lvm_id:
+ assert path == tmp_lookups[lvm_id]
+ del tmp_lookups[lvm_id]
+
+ if uuid:
+ assert path == tmp_lookups[uuid]
+ del tmp_lookups[uuid]
+
+ rc = len(tmp_lookups)
+ if rc:
+ # Error condition
+ log_error("_id_to_object_path has extraneous lookups!")
+ for key, path in tmp_lookups.items():
+ log_error("Key= %s, path= %s" % (key, path))
+ return rc
+
def _lookup_add(self, obj, path, lvm_id, uuid):
"""
Store information about what we added to the caches so that we