Cannot stop messaging listener after health policy detached
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
senlin |
In Progress
|
Undecided
|
chenyb4 |
Bug Description
We defined the message handlers in health_`manager.py` which can process incoming messages from Nova or Heat side, and we have a factory method to register the endpoint to create a listener to poll messages from target topics with the filter-rule. However:
```
listener = messaging.
transport, targets, endpoints, executor=
listener.start()
```
The code above will create a listener by the messaging driver, the driver will create an executor will threadpool silently to process the message from the MessageQueue! Once the poll message from target topic, the message will be transfer to the handler/endpoint object.
We are using ThreadGroup to start a listener:
```
return self.TG.
```
This process will `return` immediately once the listener created and started, and the return value is the `Thread` we used to create and start the listener, and it will be released immediately either.
```
# This will kill the thread, but will not stop listener
self.TG.
listener.stop()
```
This oslo.messaging provide 2 method to stop the listener:
```
@ordered(
def stop(self):
"""Stop handling incoming messages.
Once this method returns, no new incoming messages will be handled by
the server. However, the server may still be in the process of handling
some messages, and underlying driver resources associated to this
server are still in use. See 'wait' for more details.
"""
@ordered(
def wait(self):
"""Wait for message processing to complete.
After calling stop(), there may still be some existing messages
which have not been completely processed. The wait() method blocks
until all message processing has completed.
Once it's finished, the underlying driver resources associated to this
server are released (like closing useless network connections).
"""
# Close listener connection after processing all messages
```
Changed in senlin: | |
assignee: | nobody → chenyb4 (chenyb4) |
Changed in senlin: | |
status: | New → In Progress |
Hopefully, we can start the listener directly but current thread, the return value will be the Listener itself.
So that we can stop the listener if needed.