From 1e6a3e8c00a5d19b03c81e3c546c492488a5a914 Mon Sep 17 00:00:00 2001 From: Jason Peacock Date: Mon, 9 Sep 2024 10:46:15 -0500 Subject: [PATCH] Skip device configs that fail to load. ZEN-35056 --- Products/ZenCollector/services/ConfigCache.py | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Products/ZenCollector/services/ConfigCache.py b/Products/ZenCollector/services/ConfigCache.py index e61e8800c7..8dedded71d 100644 --- a/Products/ZenCollector/services/ConfigCache.py +++ b/Products/ZenCollector/services/ConfigCache.py @@ -128,10 +128,10 @@ def remote_getDeviceConfigs( return { "new": [ - self._stores.device.get(key).config for key in newest_keys + _get_configs(newest_keys, self._stores.device, self.log) ], "updated": [ - self._stores.device.get(key).config for key in updated_keys + _get_configs(updated_keys, self._stores.device, self.log) ], "removed": list(removed), } @@ -195,6 +195,25 @@ def _filter(self, keys, predicate): method("error filtering device ID %s", key.device) +def _get_configs(keys, store, log): + if log.isEnabledFor(logging.DEBUG): + mlog = log.exception + else: + mlog = log.error + for key in keys: + try: + yield store.get(key).config + except Exception as ex: + mlog( + "failed to retrieve config " + "error=%s service=%s collector=%s device=%s", + ex, + key.service, + key.monitor, + key.device, + ) + + class _DeviceProxy(object): # The predicate returned by getOptionsFilter expects an object # with an `id` attribute. So make a simple class with one attribute.