From 78128ae0ff76034ed88e63c2221672654ddf492f Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Wed, 19 Jun 2019 14:06:50 +0000 Subject: [PATCH] rabbitmq_cluster: limit queue size to 1GB and remove stale queues When a user creates a queue and then never consumes from it (such at the current Greenwave queue) it grows and grows forever. This isn't a problem in the short term as messages are very small and 100K messages is in the range of 10MB (depending on the payload size, obviously), but eventually it will lead to trouble. This policy will delete any queue that has had no subscribers in 31 days, and as a safety measure also limits all queues to 1GB of storage, which is probably excessive. Signed-off-by: Jeremy Cline --- roles/rabbitmq_cluster/tasks/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/roles/rabbitmq_cluster/tasks/main.yml b/roles/rabbitmq_cluster/tasks/main.yml index 8d96f43a09..e100a338ab 100644 --- a/roles/rabbitmq_cluster/tasks/main.yml +++ b/roles/rabbitmq_cluster/tasks/main.yml @@ -180,6 +180,24 @@ - rabbitmq_cluster - config +- name: Add a policy to limit queues to 1GB and remove after a month of no use + run_once: true + delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org" + rabbitmq_policy: + apply_to: queues + name: pubsub_sweeper + state: present + pattern: ".*" + tags: + # Unused queues are killed after 1000 * 60 * 60 * 31 milliseconds (~a month) + expires: 111600000 + # Queues can use at most 1GB of storage + max-length-bytes: 1073741824 + vhost: /pubsub + tags: + - rabbitmq_cluster + - config + - name: Create the admin user for the pubsub vhost rabbitmq_user: user: admin