From 2691e1d70735f132aa45e303430545d04db637dc Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 4 Jan 2018 11:33:47 -0500 Subject: [PATCH] make the fact caching plugin fail more gracefully for large payloads related: https://github.com/ansible/ansible/pull/34424 --- awx/plugins/fact_caching/awx.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/awx/plugins/fact_caching/awx.py b/awx/plugins/fact_caching/awx.py index 9b929a2728..207292c37e 100755 --- a/awx/plugins/fact_caching/awx.py +++ b/awx/plugins/fact_caching/awx.py @@ -92,6 +92,14 @@ class CacheModule(BaseCacheModule): modified_key = self.translate_modified_key(key) self.mc.set(host_key, json.dumps(value)) + value = json.dumps(value) + rc = self.mc.set(host_key, value) + if rc == 0 and len(value) > self.mc.server_max_value_length: + self._display.error( + "memcache.set('{}', '?') failed, value > server_max_value_length ({} bytes)".format( + key, len(value) + ) + ) self.mc.set(modified_key, datetime.datetime.now(tzutc()).isoformat()) def keys(self):