Allow for more overhead in zaqar message

We need to account for more overhad when chunking the message before
posting it to the zaqar queue as JSON encoding also adds to the overall
message length. This changes the overhead ratio from 90% down to 50%.

This would result in more smaller messages going through the queue. I
don't see any drawbacks with that though given this zaqar is not tenant
facing and is on the undercloud.

Change-Id: I79535bb276a7f763da575a022486590c117579b0
This commit is contained in:
James Slagle
2018-04-11 11:07:56 -04:00
parent 59b299cf23
commit dec6aae511
2 changed files with 12 additions and 7 deletions

View File

@@ -370,13 +370,14 @@ class AnsiblePlaybookAction(base.TripleOAction):
def post_message(self, queue, message):
"""Posts message to queue
Breaks the message up it up by maximum message size if needed.
Breaks the message up by maximum message size if needed.
"""
start = 0
# We use 90% of the max message size to account for any overhead,
# plus the wrapped dict structure from format_message
message_size = int(self.max_message_size * 0.9)
# We use 50% of the max message size to account for any overhead
# due to JSON encoding plus the wrapped dict structure from
# format_message.
message_size = int(self.max_message_size * 0.5)
while True:
end = start + message_size
message_part = message[start:end]

View File

@@ -124,7 +124,7 @@ class AnsiblePlaybookActionTest(base.TestCase):
ansible_config_path = os.path.join(action.work_dir, 'ansible.cfg')
mock_write_cfg.return_value = ansible_config_path
message_size = int(self.max_message_size * 0.9)
message_size = int(self.max_message_size * 0.5)
# Message equal to max_message_size
queue = mock.Mock()
@@ -154,7 +154,7 @@ class AnsiblePlaybookActionTest(base.TestCase):
message = ''.join([string.ascii_letters[int(random.random() * 26)]
for x in range(2048)])
action.post_message(queue, message)
self.assertEqual(queue.post.call_count, 3)
self.assertEqual(queue.post.call_count, 4)
self.assertEqual(
queue.post.call_args_list[0],
mock.call(action.format_message(message[:message_size])))
@@ -165,7 +165,11 @@ class AnsiblePlaybookActionTest(base.TestCase):
self.assertEqual(
queue.post.call_args_list[2],
mock.call(action.format_message(
message[message_size * 2:2048])))
message[message_size * 2:message_size * 3])))
self.assertEqual(
queue.post.call_args_list[3],
mock.call(action.format_message(
message[message_size * 3:2048])))
class CopyConfigFileTest(base.TestCase):