vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.27k stars 340 forks source link

update_pgcluster.yml: Use Patroni REST API instead of patronictl command to switchover #596

Closed SDV109 closed 1 month ago

SDV109 commented 1 month ago

FIX switchover in update_pgcluster.ymlwith the old version of patroni.

In the old version of patroni(example 2.1.4), the keyword Master was used, not Primary, which is why switchover does not work on older versions of Patroni. This fix uses the Patroni API, tested on version 2.1.4.

Doc: https://patroni.readthedocs.io/en/latest/rest_api.html#switchover-and-failover-endpoints

vitabaks commented 1 month ago

@SDV109 I think we need to wait for the return of code 200, which means a successful switchover. Use 'until', the example in the subsequent task of this file.

Depending on the situation, requests might return different HTTP status codes and bodies. Status code 200 is returned when the switchover or failover successfully completed. If the switchover was successfully scheduled, Patroni will return HTTP status code 202. In case something went wrong, the error status code (one of 400, 412, or 503) will be returned with some details in the response body.

SDV109 commented 1 month ago

@vitabaks, Fixed