Number of heat queues will keep growing forever after heat-engine restarts

Set TTL as a solution for topic queue engine_worker and heat-engine-listener
to avoid them growing all the time after heat-engin restarts.

This is heat part.

Closes-Bug: 1925436
Change-Id: I196346e4ca869efab45d1c2aafb1420b2a917d39
This commit is contained in:
Zhang Hua
2021-05-20 20:06:13 +08:00
parent c7cb7bb4af
commit de88ad5344
3 changed files with 20 additions and 5 deletions

View File

@ -74,6 +74,12 @@ options:
default: openstack
type: string
description: RabbitMQ virtual host to request access on rabbitmq-server.
ttl:
type: int
default: 3600000
description: |
TTL in MS for heat queues in the openstack vhost. Defaults to
1 hour, but can be tuned up or down depending on deployment requirements.
encryption-key:
default: ""
type: string

View File

@ -171,6 +171,8 @@ def config_changed():
cluster_joined(relation_id=rid)
for r_id in relation_ids('ha'):
ha_joined(relation_id=r_id)
for rid in relation_ids('amqp'):
amqp_joined(relation_id=rid)
# call the policy overrides handler which will install any policy overrides
policyd.maybe_do_policyd_overrides_on_config_changed(
@ -221,7 +223,10 @@ def upgrade_charm():
@hooks.hook('amqp-relation-joined')
def amqp_joined(relation_id=None):
relation_set(relation_id=relation_id,
username=config('rabbit-user'), vhost=config('rabbit-vhost'))
username=config('rabbit-user'), vhost=config('rabbit-vhost'),
ttlname='heat_expiry',
ttlreg='heat-engine-listener|engine_worker',
ttl=config('ttl'))
@hooks.hook('amqp-relation-changed')

View File

@ -226,14 +226,18 @@ class HeatRelationTests(CharmTestCase):
self.relation_set.assert_called_with(
username='heat',
vhost='openstack',
relation_id=None)
relation_id=None,
ttlname='heat_expiry',
ttlreg='heat-engine-listener|engine_worker',
ttl=3600000)
def test_amqp_joined_passes_relation_id(self):
"Ensures relation_id correct passed to relation_set"
relations.amqp_joined(relation_id='heat:1')
self.relation_set.assert_called_with(username='heat',
vhost='openstack',
relation_id='heat:1')
self.relation_set.assert_called_with(
username='heat', vhost='openstack', relation_id='heat:1',
ttlname='heat_expiry',
ttlreg='heat-engine-listener|engine_worker', ttl=3600000)
@patch.object(relations, 'CONFIGS')
def test_amqp_changed_relation_data(self, configs):