Skip to content

Commit

Permalink
Delete legacy rabbit queues
Browse files Browse the repository at this point in the history
When ManageIQ disconnects from the RabbitMQ service in OpenStack, it leaves
behind the queue(s) used to bind to the messaging exchange for events from Nova,
Glance, Cinder, etc...  The problem with leaving these queues behind is that
without a client to drain the queues, they keep filling up with messages from
the notifications topics of the Nova, Glance, and Cinder exchanges.

This patch will remove any legacy queues before attempting to create any new
queues when ManageIQ connects to a RabbitMQ service in OpenStack.

https://bugzilla.redhat.com/show_bug.cgi?id=1265289
  • Loading branch information
blomquisg committed Sep 22, 2015
1 parent c9fd0ce commit 57a4bd3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gems/pending/openstack/amqp/openstack_rabbit_event_monitor.rb
Expand Up @@ -93,6 +93,7 @@ def amqp_event(delivery_info, metadata, payload)
end

def initialize_queues(channel)
remove_legacy_queues
@queues = {}
if @options[:topics]
@options[:topics].each do |exchange, topic|
Expand All @@ -103,6 +104,24 @@ def initialize_queues(channel)
end
end

def remove_legacy_queues
# Rabbit queues used to be created with incorrect initializing arguments (no
# auto_delete and no exclusive). The significant problem with leaving these
# queues around is that they are not deleted when the event monitor
# disconnects from Rabbit. And the queues continue to collect messages with
# no client to drain them.
channel = connection.create_channel
@options[:topics].each do |exchange, topic|
queue_name = "miq-#{@client_ip}-#{exchange}"
channel.queue_delete(queue_name) if connection.queue_exists?(queue_name)
end

# notifications.* is a poorly named extra-old legacy queue
channel.queue_delete("notifications.*") if connection.queue_exists?(queue_name)

channel.close
end

def subscribe_queues
@queues.each do |exchange, queue|
queue.subscribe do |delivery_info, metadata, payload|
Expand Down

0 comments on commit 57a4bd3

Please sign in to comment.