From 727dcd36d81df556b4bc84fe9b88e0743d4ec326 Mon Sep 17 00:00:00 2001 From: Jason Peacock Date: Wed, 18 Sep 2024 15:14:41 -0500 Subject: [PATCH] Compress device configs when stored in Redis. ZEN-35069 --- Products/ZenCollector/configcache/cache/storage/device.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Products/ZenCollector/configcache/cache/storage/device.py b/Products/ZenCollector/configcache/cache/storage/device.py index fef4e944be..367a437296 100644 --- a/Products/ZenCollector/configcache/cache/storage/device.py +++ b/Products/ZenCollector/configcache/cache/storage/device.py @@ -64,6 +64,7 @@ import logging import re import types +import zlib from functools import partial from itertools import chain @@ -660,6 +661,10 @@ def _deserialize(data): # s-expressions, which are basically nested lists, and there's no JSON # hook for lists. So, wrap the data into a JSON-object (a dict) and # use a function to customize the decoding. + try: + data = zlib.decompress(data) + except zlib.error: + pass data = '{{"config":{}}}'.format(data) return unjelly(json.loads(data, object_hook=_decode_config)) @@ -682,7 +687,7 @@ def _decode_item(item): def _serialize(config): - return json.dumps(jelly(config)) + return zlib.compress(json.dumps(jelly(config))) def _to_score(ts):