Clean rabbitmq dump of auto-delete queues
This change adds a script that can be used on the output from the rabbitmq admin plugin that dumps the rabbitmq definitions to a json format. This script removes the auto-delete queues and cleans up any references to them in the bindings and exchanges. Change-Id: Ie3f3194b3eaaa8dc28d1cd3442090b586e177306 Closes-Bug: #1497961 Co-Authored-By: Dmitry Mescheryakov <dmescheryakov@mirantis.com>
This commit is contained in:
parent
8b72e8bd7d
commit
6e79750c29
|
@ -2,4 +2,4 @@ files/fuel-ha-utils/ocf/* /usr/lib/ocf/resource.d/fuel
|
|||
files/fuel-ha-utils/tools/wsrepclustercheckrc /etc
|
||||
files/fuel-ha-utils/tools/galeracheck /usr/bin
|
||||
files/fuel-ha-utils/tools/swiftcheck /usr/bin
|
||||
|
||||
files/fuel-ha-utils/tools/rabbitmq-dump-clean.py /usr/sbin
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
notice('MODULAR: dump_rabbitmq_definitions.pp')
|
||||
|
||||
$definitions_dump_file = '/etc/rabbitmq/definitions'
|
||||
$original_definitions_dump_file = '/etc/rabbitmq/definitions.full'
|
||||
$rabbit_hash = hiera_hash('rabbit_hash',
|
||||
{
|
||||
'user' => false,
|
||||
|
@ -16,10 +17,14 @@ if ($rabbit_enabled) {
|
|||
|
||||
exec { 'rabbitmq-dump-definitions':
|
||||
path => ['/usr/bin', '/usr/sbin', '/sbin', '/bin'],
|
||||
command => "curl -u ${rabbit_credentials} ${rabbit_api_endpoint} -o ${definitions_dump_file}",
|
||||
command => "curl -u ${rabbit_credentials} ${rabbit_api_endpoint} -o ${original_definitions_dump_file}",
|
||||
}->
|
||||
exec { 'rabbitmq-dump-clean':
|
||||
path => ['/usr/bin', '/usr/sbin', '/sbin', '/bin'],
|
||||
command => "rabbitmq-dump-clean.py < ${original_definitions_dump_file} > ${definitions_dump_file}",
|
||||
}
|
||||
|
||||
file { $definitions_dump_file:
|
||||
file { [$definitions_dump_file, $original_definitions_dump_file]:
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# This script accepts a json dump via stdin that was generated by calling the
|
||||
# rabbitmq /api/definitions endpoint. It then removes the queues, bindings and
|
||||
# exchanges that should not be restored if the dump was loaded and prints
|
||||
# the json back out to stdout.
|
||||
#
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
defs = json.loads(sys.stdin.read())
|
||||
|
||||
newqueues = []
|
||||
allqueues = set()
|
||||
|
||||
# delete all auto-delete queues
|
||||
for queue in defs['queues']:
|
||||
if not queue['auto_delete']:
|
||||
newqueues.append(queue)
|
||||
allqueues.add(queue['name'])
|
||||
|
||||
newbindings = []
|
||||
allsources = set()
|
||||
|
||||
# delete all bindings pointing to auto-delete queues
|
||||
for binding in defs['bindings']:
|
||||
if binding['destination'] in allqueues:
|
||||
newbindings.append(binding)
|
||||
allsources.add(binding['source'])
|
||||
|
||||
newexchanges = []
|
||||
|
||||
# delete all exchanges which were left without bindings
|
||||
for exchange in defs['exchanges']:
|
||||
if exchange['name'] in allsources:
|
||||
newexchanges.append(exchange)
|
||||
|
||||
defs['queues'] = newqueues
|
||||
defs['bindings'] = newbindings
|
||||
defs['exchanges'] = newexchanges
|
||||
|
||||
print(json.dumps(defs))
|
|
@ -60,6 +60,7 @@ mkdir -p %{buildroot}/etc/profile.d/
|
|||
mkdir -p %{buildroot}/etc/init.d/
|
||||
mkdir -p %{buildroot}/etc/dockerctl
|
||||
mkdir -p %{buildroot}/usr/bin/
|
||||
mkdir -p %{buildroot}/usr/sbin/
|
||||
mkdir -p %{buildroot}/usr/lib/
|
||||
mkdir -p %{buildroot}/usr/share/dockerctl
|
||||
mkdir -p %{buildroot}/sbin/
|
||||
|
@ -99,6 +100,7 @@ install -m 0755 %{files_source}/fuel-ha-utils/ocf/ceilometer-agent-compute %{bui
|
|||
install -m 0755 %{files_source}/fuel-ha-utils/tools/galeracheck %{buildroot}/usr/bin/galeracheck
|
||||
install -m 0755 %{files_source}/fuel-ha-utils/tools/swiftcheck %{buildroot}/usr/bin/swiftcheck
|
||||
install -m 0644 %{files_source}/fuel-ha-utils/tools/wsrepclustercheckrc %{buildroot}/etc/wsrepclustercheckrc
|
||||
install -m 0755 %{files_source}/fuel-ha-utils/tools/rabbitmq-dump-clean.py %{buildroot}/usr/sbin/rabbitmq-dump-clean.py
|
||||
install -m 0755 %{files_source}/rabbit-fence/rabbit-fence.py %{buildroot}/usr/bin/rabbit-fence.py
|
||||
install -m 0755 %{files_source}/rabbit-fence/rabbit-fence.init %{buildroot}/etc/init.d/rabbit-fence
|
||||
#FIXME - may be we need to put this also into packages
|
||||
|
@ -210,6 +212,7 @@ For further information go to http://wiki.openstack.org/Fuel
|
|||
/usr/lib/ocf/resource.d/fuel
|
||||
/usr/bin/galeracheck
|
||||
/usr/bin/swiftcheck
|
||||
/usr/sbin/rabbitmq-dump-clean.py
|
||||
%config(noreplace) /etc/wsrepclustercheckrc
|
||||
#
|
||||
|
||||
|
|
|
@ -6,6 +6,14 @@ describe manifest do
|
|||
shared_examples 'catalog' do
|
||||
it "should contain rabbitmq dump definitions exec" do
|
||||
should contain_exec('rabbitmq-dump-definitions')
|
||||
should contain_exec('rabbitmq-dump-clean')
|
||||
['/etc/rabbitmq/definitions', '/etc/rabbitmq/definitions.full'].each do |f|
|
||||
should contain_file(f).with(
|
||||
:ensure => 'file',
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:mode => '0600')
|
||||
end
|
||||
end
|
||||
end
|
||||
test_ubuntu_and_centos manifest
|
||||
|
|
Loading…
Reference in New Issue