cybertec-postgresql / vip-manager

Manages a virtual IP based on state kept in etcd or Consul
BSD 2-Clause "Simplified" License
207 stars 41 forks source link

Feature watch etcd #197

Closed dreamingdeer closed 9 months ago

dreamingdeer commented 9 months ago

With watch wee get fast swiching vip add without periodicaly GET request from etcd.

Jan 16 04:19:34 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:34 IP address 192.168.0.104/24 state is false, desired false
Jan 16 04:19:44 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:44,494 INFO: no action. I am (pgsql-pg3), a secondary, and following a leader (pgsql-pg1)
Jan 16 04:19:44 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:44 IP address 192.168.0.104/24 state is false, desired false
Jan 16 04:19:53 pgsql-pg3 vip-manager[30041]: Event received! DELETE executed on "/service/db24/leader" with value ""
Jan 16 04:19:53 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:53,991 INFO: Got response from pgsql-pg2 http://192.168.0.112:8008/patroni: {"state": "running", "postmaster_start_time": "2024-01-15 15:43:08.939758+00:00", "role": "replica", "server_version": 140010, "xlog": {"received_location": 285212672, "replayed_location": 285212672, "replayed_timestamp": null, "paused": false}, "timeline": 3, "replication_state": "streaming", "cluster_unlocked": true, "dcs_last_seen": 1705378793, "database_system_identifier": "7324036770697969623", "patroni": {"version": "3.2.0", "scope": "db24", "name": "pgsql-pg2"}}
Jan 16 04:19:54 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:54 IP address 192.168.0.104/24 state is false, desired false
Jan 16 04:19:55 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:55,972 WARNING: Request failed to pgsql-pg1: GET http://192.168.0.111:8008/patroni (HTTPConnectionPool(host='192.168.0.111', port=8008): Max retries exceeded with url: /patroni (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f7e6c2fca00>, 'Connection to 192.168.0.111 timed out. (connect timeout=2)')))
Jan 16 04:19:56 pgsql-pg3 vip-manager[30041]: Event received! PUT executed on "/service/db24/leader" with value "pgsql-pg3"
Jan 16 04:19:56 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:56 IP address 192.168.0.104/24 state is false, desired true
Jan 16 04:19:56 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:56 Configuring address 192.168.0.104/24 on eth0
Jan 16 04:19:56 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:56,137 INFO: Software Watchdog activated with 25 second timeout, timing slack 15 seconds
Jan 16 04:19:56 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:56 Sent gratuitous ARP reply
Jan 16 04:19:56 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:56 Sent gratuitous ARP request
Jan 16 04:19:56 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:19:56 IP address 192.168.0.104/24 state is true, desired true
Jan 16 04:19:56 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:56,414 INFO: promoted self to leader by acquiring session lock
Jan 16 04:19:56 pgsql-pg3 patroni[31521]: server promoting
Jan 16 04:19:56 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:56,414 INFO: Lock owner: pgsql-pg3; I am pgsql-pg3
Jan 16 04:19:56 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:56,768 INFO: updated leader lock during promote
Jan 16 04:19:59 pgsql-pg3 patroni[25985]: 2024-01-16 04:19:59,368 INFO: no action. I am (pgsql-pg3), the leader with the lock
Jan 16 04:20:04 pgsql-pg3 vip-manager[30041]: 2024/01/16 04:20:04 IP address 192.168.0.104/24 state is true, desired true