make the fact caching plugin fail more gracefully for large payloads

related: https://github.com/ansible/ansible/pull/34424
This commit is contained in:
Ryan Petrello 2018-01-04 11:33:47 -05:00
parent 6d413bd412
commit 2691e1d707
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -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):