Commit Graph
101 Commits
Author SHA1 Message Date
Alexander Kukushkin d202f72a42 Added simple web server which shows current state of postgres
Server always returns json which contains some status of postgres:
* instance type: master/slave
* xlog location for master
* xlog received_location, replayed_location
This server could be used by haproxy
GET / returns 200 if there is postgres master behind governor.
GET /slave returns 200 is there is postgres slave behind governor
In all other cases it returns 503
Currently server always listening on 0.0.0.0:8080, but it should be
configurable. In the next versions this rest api could also report some
status of etcd and could be used by is_healthiest_node method
2015-05-23 20:29:51 +02:00
Alexander Kukushkin f53c369c69 Connect timeout 5 seconds for psycopg2
Refactored query and is_healthiest_node methods
query method wont retry more then 3 times if OperationalError raised
is_healthiest_node takes into account that one of the nodes could be
still a master
2015-05-23 20:21:13 +02:00
Alexander Kukushkin 34f9b666cf Demote master when etcd is not accessible 2015-05-22 12:26:19 +02:00
Alexander Kukushkin 09163ac454 If there is no connect_address defined in yml file use address from listen as a fallback 2015-05-22 12:03:43 +02:00
Alexander Kukushkin 62d17d68de Use "member_ttl" with default value=3600 for members 2015-05-22 12:00:07 +02:00
Alexander Kukushkin 096e6e4556 Eventually member will expire in etcd 2015-05-22 11:55:20 +02:00
Alexander Kukushkin bb884bac00 Move is_unlocked method from Ha into Cluster class 2015-05-22 11:45:09 +02:00
Alexander Kukushkin 4a4d9b85e5 Make sure that there is the new line at the end of pg_hba.con 2015-05-22 11:23:11 +02:00
Alexander Kukushkin 3533b790cb Update list of success return codes for PUT and DELETE 2015-05-20 12:03:12 +02:00
Alexander Kukushkin 8378315b6d Remove unneeded stuff from setup.py 2015-05-19 14:14:52 +02:00
Alexander Kukushkin 0d5bb48ead Close connection when querying other members of cluster 2015-05-19 14:01:30 +02:00
Alexander Kukushkin 8946b28c51 Merge pull request #1 from CyberDem0n/testing
some simple tests
2015-05-19 13:55:38 +02:00
Alexander Kukushkin 16974ad752 do not test against 2.6 2015-05-19 13:32:35 +02:00
Alexander Kukushkin c8ee7b1c6d test against 2.6 and 3.3 2015-05-19 13:05:31 +02:00
Alexander Kukushkin 004cbf16c6 Merge branch 'master' of github.com:CyberDem0n/governor into testing 2015-05-19 13:01:15 +02:00
Alexander Kukushkin 805b3a04fc trigger rebuild 2015-05-19 12:59:37 +02:00
Alexander Kukushkin ebb8bce0f6 some simple tests 2015-05-19 12:49:53 +02:00
Alexander Kukushkin 3e8855799f Add requirements.txt 2015-05-19 09:14:13 +02:00
Alexander Kukushkin f7b6c8df40 Merge branch 'master' of github.com:CyberDem0n/governor
Conflicts:
	helpers/postgresql.py
2015-05-18 15:58:38 +02:00
Alexander Kukushkin e9ffcf9efe Small refactoring of initdb call 2015-05-18 15:57:24 +02:00
Alexander Kukushkin 520de12232 Remove debug print 2015-05-18 14:39:14 +02:00
Alexander Kukushkin a9b50b4e2e Merge branch 'master' of github.com:CyberDem0n/governor 2015-05-18 14:34:17 +02:00
Alexander Kukushkin ce936ceee2 Merge branch 'master' of github.com:compose/governor
Conflicts:
	governor.py
	helpers/ha.py
	helpers/postgresql.py
2015-05-18 14:33:27 +02:00
Alexander Kukushkin 422512880f last_leader_operation is the propery of Cluster object and the value is set in get_cluster method 2015-05-18 13:43:14 +02:00
Alexander Kukushkin b24fb0488c last_leader_operation is the propery of Cluster object and the value is set in get_cluster method 2015-05-18 13:33:27 +02:00
Alexander Kukushkin d221d1de1c listen_address can have more then one value separated by comma. We will use the first one to connect 2015-05-18 10:53:27 +02:00
Alexander Kukushkin 348100752b Open connection to self via listen address 2015-05-15 16:18:31 +02:00
Alexander Kukushkin af9ebfa3b9 Use connect_address instead of listen when building connection_string 2015-05-15 12:20:24 +02:00
Alexander Kukushkin 75ff91d017 rename connection_address to connect_address 2015-05-15 12:13:05 +02:00
Alexander Kukushkin 08865512f8 Differentiate between connection address and listen address
For example you can listen on 0.0.0.0 but provide service on some
didicated ip. This should cover all possible use-cases when you are
running behind firewall, load balancer or inside for example docker.
2015-05-15 12:06:04 +02:00
Alexander Kukushkin 274bc14bfb Do not check maximum_lag_on_failover if it is not defined in config file 2015-05-15 11:38:50 +02:00
Alexander Kukushkin 8e5beb5883 Small optimization 2015-05-15 11:25:26 +02:00
Alexander Kukushkin 9487aec842 Bugfix: get_client_path might get into infinite loop when response code is not 200 2015-05-15 11:23:02 +02:00
Christopher Winslett a4e40959f9 fix linking syntax in README 2015-05-14 14:18:52 -07:00
Christopher Winslett 94ae8b0c0d Merge pull request #10 from compose/support-synchronous-replication
Support synchronous replication
2015-05-14 14:16:48 -07:00
Christopher Winslett bec1a3c11e support synchronous replication 2015-05-14 14:16:18 -07:00
Christopher Winslett 96a889f358 fix logic for dead leaders returning online
without checking that recovery.conf exists, the prior logic would not create the recovyer.conf, and a dead leader would return to a primary state
2015-05-13 16:56:25 -07:00
Christopher Winslett 3b0ea900cd followers without a leader based on feedback from @CyberDem0n and closes #3 2015-05-13 16:37:28 -07:00
Alexander Kukushkin 4e8a0873a7 Handle sigchld, so we can run governor and postgres inside docker safely 2015-05-13 18:05:42 +02:00
Alexander Kukushkin e6e19359df Bugfix, write state_handler.name into leader key 2015-05-13 18:04:27 +02:00
Alexander Kukushkin 0c040b8ce2 Merge branch 'master' of github.com:compose/governor
Conflicts:
	governor.py
	helpers/etcd.py
	helpers/ha.py
	helpers/postgresql.py
2015-05-13 18:01:01 +02:00
Alexander Kukushkin 40a4192504 Remove member and leader (is I was the master) keys from etcd on stop of governor 2015-05-13 17:12:17 +02:00
Alexander Kukushkin d25ad17c32 Add support of python3 2015-05-13 14:53:23 +02:00
Christopher Winslett f8c4993f16 add description of settings for yaml file 2015-05-12 18:53:57 -07:00
Christopher Winslett 2c69074652 move stale protection from is_healthy to is_healthiest to allow stale secondaries to rejoin cluster 2015-05-12 18:29:54 -07:00
Christopher Winslett 557bad37cd ensure a stale Postgres does not become leader 2015-05-12 18:11:12 -07:00
Christopher Winslett a1bc07db33 use TTLs with member listing to keep a current list of cluster members 2015-05-12 16:33:32 -07:00
Alexander Kukushkin 8b38dbd2b5 Put governor code into class and implement sigterm processing handler 2015-05-12 13:48:06 +02:00
Alexander Kukushkin 281b0b8455 Bugfix in has_lock: sometimes leader can be undefined 2015-05-12 11:07:52 +02:00
Alexander Kukushkin 9dcbc75fd2 Bugfix. It wasn't possible to start the old cluster if all its members were shutdown.
Basically this is rollback to the original decision tree with the small exception:
1 - If leader is defined and it's not me - then slave would be started immidiately
with the correct recovery conf.
2 - If leader is defined in and it's my host, then it will start instance in
readonly (but without primary_conninfo in recovery.conf)
3 - And the third case - if the leader is not defined - it also will start
instance in readonly, without primary_conninfo.
After performing 2 or 3 it will perform usual decision tree.
2015-05-12 10:19:45 +02:00