def stop(): """Gracefully remove ourself from RabbitMQ cluster before unit is removed If RabbitMQ have objections to node removal, for example because of this being the only disc node to leave the cluster, the operation will fail and unit removal will be blocked with error for operator to investigate. In the event of a unit being forcefully or abrubtly removed from the cluster without a chance to remove itself, it will be left behind as a stopped node in the RabbitMQ cluster. Having a dormant no longer existing stopped node lying around will cause trouble in the event that all RabbitMQ nodes are shut down. In such a situation the cluster most likely will not start again without operator intervention as RabbitMQ will want to interrogate the now non-existing stopped node about any queue it thinks it would be most likely to have authoritative knowledge about. For this reason any abruptly removed nodes will be cleaned up periodically by the leader unit during its update-status hook run. This call is placed in stop hook and not in the cluster-relation-departed hook because the latter is not called on the unit being removed. """ rabbit.leave_cluster()