From c476e31f769cfa0cb499b5efdaa3fa201a871868 Mon Sep 17 00:00:00 2001 From: DJ Enriquez Date: Wed, 12 Oct 2016 10:44:35 -0700 Subject: [PATCH] Split out transactions to 10 keys per Doing everything in one transaction risks a 413: Request Entity Too Large --- src/consul.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/consul.py b/src/consul.py index 6672e30..c2fdada 100644 --- a/src/consul.py +++ b/src/consul.py @@ -25,11 +25,10 @@ def restore_kv(self, restore_file): for line in restore_file: kv = line.split(':') - logger.debug('Key: {}, Value: {}'.format(kv[0], base64.standard_b64decode(kv[1]).decode('utf-8'))) - transaction_data.append({ 'KV' : { 'Verb': 'set', 'Key': kv[0], 'Value': kv[1] } }) - self._upload_kv(transaction_data) + for x in range(0, len(transaction_data), 10): + self._upload_kv(transaction_data[x:x+10]) def _upload_kv(self, transaction_data): headers = { 'X-Consul-Token': self._token } if self._token is not None else {}