Commit Graph
100 Commits
Author SHA1 Message Date
Alexander Kukushkin 5ea0ab70f5 Add patroni.py executable file 2015-09-07 10:37:10 +02:00
Alexander Kukushkin 650e244904 Refactor directory structure in preparation for building pypi-package 2015-09-04 16:06:44 +02:00
Alexander Kukushkin a69565fc5f Set Postgresql._SERVER_VERSION only after real connect. 2015-09-04 13:22:44 +02:00
Alexander Kukushkin c913c8ad92 Calculate xlog bytes with using lsn_to_bytes method
This method behaves differently depending on server version and will
allow to use patroni with postgres older than 9.3
2015-09-04 12:11:55 +02:00
Alexander Kukushkin 8b9e99090f Move lsn_to_bytes and bytes_to_lsn into Postgresql class
and make their behavior version specific
2015-09-04 10:41:59 +02:00
Alexander Kukushkin 9361732722 Fix pep8 formatting and unit-tests 2015-09-04 08:29:16 +02:00
Alexander Kukushkin 50420771ce Retry when executing take_leader method. 2015-09-03 16:53:15 +02:00
Alexander Kukushkin 2f6399de27 More unit-tests for etcd 2015-09-03 16:35:58 +02:00
Alexander Kukushkin 66286733b2 Enable retry functionality for etcd with default deadline=10 seconds 2015-09-03 15:03:09 +02:00
Alexander Kukushkin 8d99fd17a0 Merge branch 'master' of github.com:zalando/patroni into feature/retry 2015-09-03 13:18:58 +02:00
Alexander Kukushkin e8b2fb112b It is better to reap childs before running relatively long sleep 2015-09-03 11:50:58 +02:00
Alexander Kukushkin 58410db9dd Implemented Retry class inspired by KazooRetry 2015-09-03 11:47:08 +02:00
Alexander Kukushkin 7456662eef Merge branch 'master' of github.com:zalando/patroni into feature/watch-leader-key 2015-09-03 10:33:26 +02:00
Alexander Kukushkin a670b598f4 Implement unit test for reap_children function 2015-09-02 16:48:40 +02:00
Alexander Kukushkin 7eed8521d0 Merge branch 'master' of github.com:zalando/patroni into feature/watch-leader-key 2015-09-02 13:33:44 +02:00
Alexander Kukushkin a7f7a7bf58 Remove spurious print 2015-09-02 13:33:07 +02:00
Alexander Kukushkin 7cdb5f7138 Merge branch 'master' of github.com:zalando/patroni into feature/watch-leader-key 2015-09-02 13:28:14 +02:00
Alexander Kukushkin 8bc9d00391 Code cleanup 2015-09-02 13:26:40 +02:00
Alexander Kukushkin 0beecb97a7 Reschedule next ha loop after promote 2015-09-02 13:25:33 +02:00
Alexander Kukushkin c6abf85740 Bugfix: sleep method was renamed to watch 2015-09-02 08:42:47 +02:00
Alexander Kukushkin eb85caa3bd Remove spurious print 2015-09-01 17:16:15 +02:00
Alexander Kukushkin 3924a90c74 Create conn_url propery in a Leader object 2015-09-01 16:43:28 +02:00
Alexander Kukushkin 5a0634d7b0 Create name property in a Cluster object
It returns self.member.name and simplifies later usage in code.
2015-09-01 16:37:03 +02:00
Alexander Kukushkin 10c95a23e4 Rename sleep to watch in a AbstractDCS
This method suppose to watch for changes of leader key if current node
is not leader and also it could watch for changes in a members list if
current conde is the leader.
2015-09-01 09:59:37 +02:00
Alexander Kukushkin fab321c6b0 Watch for changes of leader key 2015-09-01 09:54:57 +02:00
Alexander Kukushkin 3b1efff53e Refactor Cluster object
`Cluster.leader` is not reference to `Member` anymore, but to `Leader`
`Leader` class contains field `index` (update index). This field is very
useful for watching for events which changing leader key. Also `Leader`
contains `member` field, which should reference real member.
2015-08-27 10:53:22 +02:00
Alexander Kukushkin 65d3df3ec0 Merge branch 'master' of github.com:zalando/patroni into feature/python-etcd 2015-08-26 15:23:42 +02:00
Alexander Kukushkin c2aaa876d2 Merge branch 'feature/cloexec' of github.com:zalando/patroni into feature/python-etcd 2015-08-26 15:18:02 +02:00
Alexander Kukushkin 60a360a4da Reset _machines_cache before doing next load attempt 2015-08-26 15:17:24 +02:00
Alexander Kukushkin 353fc58bee Do not inherit rest api port on fork 2015-08-26 15:14:44 +02:00
Alexander Kukushkin 420176aa75 Merge branch 'master' of github.com:zalando/patroni into feature/python-etcd 2015-08-25 10:11:29 +02:00
Alexander Kukushkin befd33555d Refactor helpers/etcd.py
Work with etcd cluster via high-level python-etcd module.
Plus change all unit tests accordingly.
2015-08-24 16:58:08 +02:00
Alexander Kukushkin 72043703f5 Small code cleanup 2015-08-17 16:06:48 +02:00
Alexander Kukushkin ce6d1c69d8 Merge branch 'master' of github.com:zalando/patroni into feature/six 2015-08-11 10:19:35 +02:00
Alexander Kukushkin e9d46b0adb Merge branch 'master' of github.com:zalando/patroni into feature/lost-dcs-data 2015-08-11 10:19:07 +02:00
Alexander Kukushkin d2f956e87f Write some documentation in a dockstring format for AbstractDCS class 2015-08-11 10:17:55 +02:00
Alexander Kukushkin b6c2061f3a Merge branch 'master' of github.com:zalando/patroni into feature/six 2015-07-15 12:49:51 +02:00
Alexander Kukushkin 26935c3725 Merge branch 'master' of github.com:zalando/patroni into feature/lost-dcs-data 2015-07-15 12:49:38 +02:00
Alexander Kukushkin 66f4f790d2 Improve test coverage 2015-07-15 12:49:17 +02:00
Alexander Kukushkin 9df783cf9d use six module to support python 2 and 3 instead of conditional imports 2015-07-15 12:03:28 +02:00
Alexander Kukushkin b54119b918 Run is_healthiest_node against last know healthy configuration of cluster
This will help to survive when everything was wiped from configuration
store.
2015-07-15 11:20:25 +02:00
Alexander Kukushkin 71fce312c2 Enforce flake8 check 2015-07-10 10:53:04 +02:00
Alexander Kukushkin dcad7a3229 Add exhibitor support
List of ZooKeeper nodes could be periodically updated from Exhibitor
Since we know that each Exhibitor accompanies one ZooKeeper node, list
of Exhibitor nodes also maintained. Exhibitor assumes that all ZooKeeper
nodes are using the same client port, 2181. The same assumption is valid
for Exhibitor, it should always listen on the same port on all nodes.

Original list of Exhibitor nodes is cached and used as a fallback when
it failed ito query information with using maintained list.
2015-07-10 10:46:33 +02:00
Alexander Kukushkin cc291ecf1b Add Zalando to copyright 2015-07-08 11:16:33 +02:00
Alexander Kukushkin c49580d6a7 Rename governor into patroni 2015-07-08 10:37:35 +02:00
Alexander Kukushkin 259c3ac341 Merge branch 'multidcs' of github.com:CyberDem0n/governor into feature/multidcs 2015-07-08 08:54:02 +02:00
Alexander Kukushkin 00aa99b38f Revert restapi port to 8009 2015-07-08 08:53:51 +02:00
Alexander Kukushkin a1f11fe2fe Remove unneeded class CurrentLeaderError 2015-07-08 08:53:08 +02:00
Alexander Kukushkin 54400c6dec Merge branch 'multidcs' of github.com:CyberDem0n/governor into feature/multidcs
Conflicts:
	governor.py
	tests/test_governor.py
	tests/test_postgresql.py
2015-07-08 08:47:26 +02:00
Alexander Kukushkin 43b12af3a7 Implement possibility to work against ZooKeeper
This implementation is using the same interface (AbstractDCS) as Etcd
class. It means that there should be no problem to implement another
plugin to work agains Consul for example.
2015-07-07 12:45:14 +02:00
Alexander Kukushkin 7445590546 Keep node name in AbstractDCS class
It eliminates need to pass this name into most of the methods
2015-07-07 12:26:52 +02:00
Alexander Kukushkin c5edcb589b return result of last_operation as a string 2015-07-07 12:24:02 +02:00
Alexander Kukushkin 1531304baa return result of last_operation as a string 2015-07-07 12:23:06 +02:00
Alexander Kukushkin ae689a2f83 Rename ha.etcd into ha.dcs 2015-07-02 15:33:21 +02:00
Alexander Kukushkin cc71906009 Inherit Etcd from abstract class 2015-07-02 15:15:07 +02:00
Alexander Kukushkin 6079c8359f refactoring: preparing to support ZooKeeper
move some common classes info separate file in preparation to support distributed configuration store other then Etcd
2015-07-02 12:06:07 +02:00
Alexander Kukushkin 687fb7da10 Remove haproxy_status.sh and change haproxy.cfg to work directly with the governor 2015-06-25 14:17:51 +02:00
Alexander Kukushkin a723dbbed4 Merge branch 'master' of github.com:compose/governor 2015-06-25 14:15:52 +02:00
Alexander Kukushkin 9732106e5d BUGFIX: keep list of replication slots on slaves empty
Otherwise slaves accumulate wal files...
2015-06-25 14:01:06 +02:00
Alexander Kukushkin ffdd3b3d8e Merge branch 'master' of github.com:CyberDem0n/governor 2015-06-24 16:42:08 +02:00
Alexander Kukushkin a02f9d497f BUGFIX: it can be that /members request to etcd returns somesing strange with status_code 200 2015-06-24 16:41:37 +02:00
Alexander Kukushkin f7be52f63a real_ttl method will return -1 when expiration is not defined 2015-06-23 17:15:37 +02:00
Alexander Kukushkin b7c73fdba8 Rename hostname to name in a Member 2015-06-23 14:07:00 +02:00
Alexander Kukushkin 744026b4bb Do not update member TTL when it is far from being expired 2015-06-23 14:02:32 +02:00
Alexander Kukushkin 44e06b4cff Add expiration field into Member 2015-06-10 14:22:11 +02:00
Alexander Kukushkin 275e18e58a Refactor tests 2015-06-10 14:21:23 +02:00
Alexander Kukushkin 72b980bd97 Merge branch 'etcd-cluster-support' of github.com:CyberDem0n/governor 2015-06-10 11:58:48 +02:00
Alexander Kukushkin 971bc3b6e8 Increase verbosity of failed PUT and DELETE requests. Hope will help to debug some etcd related issues 2015-06-10 11:56:16 +02:00
Alexander Kukushkin 3f47e9e362 Merge branch 'etcd-cluster-support' of github.com:CyberDem0n/governor 2015-06-09 15:47:06 +02:00
Alexander Kukushkin a64dad267e Bugfix: target field of SRV object should be casted to string 2015-06-09 15:46:34 +02:00
Alexander Kukushkin 4fa9dbcf03 Merge branch 'etcd-cluster-support' of github.com:zalando/governor into etcd-cluster-support 2015-06-09 12:31:52 +02:00
Alexander Kukushkin de7630c65c Merge branch 'etcd-cluster-support' of github.com:CyberDem0n/governor into etcd-cluster-support 2015-06-09 12:31:09 +02:00
Alexander Kukushkin 57914821d0 Randomize list of etcd cluster members 2015-06-09 12:30:58 +02:00
Alexander Kukushkin a2988361c5 Retry with host from config when it failed to resolve SRV 2015-06-09 12:30:16 +02:00
Alexander Kukushkin 19b0d4701b Merge branch 'etcd-cluster-support' of github.com:CyberDem0n/governor into etcd-cluster-support
Conflicts:
	requirements-py2.txt
	tests/test_governor.py
2015-06-09 11:34:14 +02:00
Alexander Kukushkin 261fbf2721 Replace logging with logger in ha.py 2015-06-09 10:27:09 +02:00
Alexander Kukushkin da4f9e8445 Make logging of http requests more verbose 2015-06-09 10:25:33 +02:00
Alexander Kukushkin 5b7a60657f Fix syntax in .travis.yml 2015-06-09 10:04:07 +02:00
Alexander Kukushkin c79fba7656 Support work with etcd as a cluster
In case if one member of a cluster is not available it will retry with
another one and fetch the new cluster configuration. Default timeout for
all requests to etcd is 5 seconds.
Initial cluster configuration can be resolved through:
1) /v2/members call on one of the cluster members on a client port
2) when it is possible to resolve hostname into multiple ip's  it will
iterate through list and try to perform action from 1)
3) If there is discovery_srv defined in etcd section of config file it
will resolve peer addresses of all cluster members and will fetch
cluster configuration with using peer protocol by doing /members call on
a peer port
2015-06-09 09:51:53 +02:00
Alexander Kukushkin fad2fbeae0 Import ThreadingMixIn for python3 2015-06-03 16:39:29 +02:00
Alexander Kukushkin aa1fc315ae Process http requests in a threads with ThreadingMixIn 2015-06-03 16:22:05 +02:00
Alexander Kukushkin f9fbe8980f Implement lsn_to_bytes bytes_to_lsn functions 2015-06-02 13:36:36 +02:00
Alexander Kukushkin 5cceac7621 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring
Conflicts:
	tests/test_postgresql.py
2015-06-02 12:38:45 +02:00
Alexander Kukushkin d9fbbf3ae9 Make pg_hba section more compact 2015-06-02 12:37:26 +02:00
Alexander Kukushkin 88631e14fa Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring
Conflicts:
	helpers/postgresql.py
	tests/test_postgresql.py
2015-06-02 10:28:28 +02:00
Alexander Kukushkin fca987deda set value of api_url from application_name parameter of conn_url. Reset parameters of conn_url 2015-06-02 09:45:37 +02:00
Alexander Kukushkin f9ce29d49f rename address to conn_url in a Member obj
and introduce new field: api_url
2015-06-02 08:52:34 +02:00
Alexander Kukushkin bacd05d99e Determine preferable local address to connect through.
If listen contains '*' or 0.0.0.0 - connect via localhost
In all other cases pick the first one.
2015-06-01 17:00:15 +02:00
Alexander Kukushkin efccd777b2 rename pid_path to postmaster_pid 2015-06-01 16:47:56 +02:00
Alexander Kukushkin 1bcc2b5fa6 Extend postgres?.yml with pg_hba section to give possibility to customize pg_hba.conf 2015-06-01 16:05:35 +02:00
Alexander Kukushkin ccdff5ea99 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring
Conflicts:
	helpers/postgresql.py
	tests/test_postgresql.py
2015-06-01 14:14:53 +02:00
Alexander Kukushkin adcc7ac256 Try to avoid "double" promotion.
Also check presence of trigger_file on master after promotion when
pg_is_in_recovery() = false and if it is there - remove it.
Plus check presence of trigger_file on a new slave (after running
pg_basebackup) and if it is there - also remove it.
2015-06-01 13:48:44 +02:00
Alexander Kukushkin 8c4e547d7a Handle KeyboardInterrupt in the main loop 2015-06-01 12:02:46 +02:00
Alexander Kukushkin 939254021e Code cleanup: do not modify os.environ but pass copy of it to subprocess.call 2015-06-01 11:03:06 +02:00
Alexander Kukushkin f8c3582715 Refactor api:
Call is_running only when it's not possible to execute query against
governed postgres.
2015-06-01 10:48:16 +02:00
Alexander Kukushkin b85262637d Bugfix: do not create replication slot for master 2015-06-01 09:20:24 +02:00
Alexander Kukushkin 5fcb19b817 Merge branch 'sleep-sigchld' of github.com:CyberDem0n/governor into features/refactoring
Conflicts:
	tests/test_governor.py
2015-05-28 15:55:03 +02:00
Alexander Kukushkin aa486194ae Wrap time.sleep into wrapper function
In case if it was interrupted by SIGCHLD but scheduled awake time is not
reached it will continue sleeping. For all other signals behaviuor is
not changed.
2015-05-28 15:47:51 +02:00
Alexander Kukushkin 9cd7000d7f Merge branch 'master' of github.com:CyberDem0n/governor 2015-05-28 13:04:49 +02:00
Alexander Kukushkin cd5e589620 Revert previous commit (restore sigchld_handler) 2015-05-28 13:04:21 +02:00