Skip to content

Commit 38013fd

Browse files
committed
Add "max-size" to limit output records sent to the messenger
1 parent 247cd8c commit 38013fd

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

caso/messenger/ssm.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
cfg.StrOpt('output_path',
3232
default='/var/spool/apel/outgoing/openstack',
3333
help="Directory to put the generated SSM records."),
34+
cfg.IntOpt('max_size',
35+
default=100,
36+
help="Maximum number of records to send per message"),
3437
]
3538

3639
CONF = cfg.CONF
@@ -63,14 +66,18 @@ def push(self, records):
6366
aux += "%s: %s\n" % (k, v)
6467
entries.append(aux)
6568

66-
message = "%s\n" % self.header
67-
68-
sep = "%s\n" % self.separator
69-
message += "%s" % sep.join(entries)
70-
7169
# FIXME(aloga): try except here
7270
queue = dirq.QueueSimple.QueueSimple(CONF.ssm.output_path)
73-
queue.add(message)
71+
72+
# Divide message into smaller chunks as per GGUS #143436
73+
# https://ggus.eu/index.php?mode=ticket_info&ticket_id=143436
74+
for i in range(0, len(entries), CONF.ssm.max_size):
75+
message = "%s\n" % self.header
76+
77+
sep = "%s\n" % self.separator
78+
message += "%s" % sep.join(entries[i:i + CONF.ssm.max_size])
79+
80+
queue.add(message)
7481

7582

7683
class SSMMessengerV02(_SSMBaseMessenger):

etc/caso/caso.conf.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,6 @@
294294

295295
# Directory to put the generated SSM records. (string value)
296296
#output_path = /var/spool/apel/outgoing/openstack
297+
298+
# Maximum number of records to send per message (integer value)
299+
#max_size = 100

0 commit comments

Comments
 (0)