When re-creating a cluster it may never become ready
Summary
After deleting an SGCluster (or SGDistributedLogs) sometimes, when re-creating, it may never become ready.
Current Behaviour
Sometimes the Patroni pod is still running when the endpoints are already deleted by the garbage collector after removing the owner SGCluster (or SGDistributedLogs). Then Patroni re-create them with the current state of the cluster. When the cluster is then re-created the endpoints maintains the old status thus when Patroni start it never becomes the leader since the data is empty.
Steps to reproduce
- Create a cluster
- Remove it
- Re-create the same cluster
Expected Behaviour
The cluster always becomes ready
Possible Solution
Disallow endpoints creations to the Patroni ServiceAccount.
Environment
- StackGres version: 1.1.0-SNAPSHOT
- Kubernetes version: ?
- Cloud provider or hardware configuration: ?