Commit Graph
537 Commits
Author SHA1 Message Date
Oleksii Kliukin ea910a8987 Make sure pgpass file name is also passed in the PGPASSFILE environment variable. 2015-09-30 18:02:07 +02:00
Oleksii Kliukin b223319183 use the PATH to get the python interpreter path for the scripts. 2015-09-30 18:00:28 +02:00
Oleksii Kliukin d7403f999d Merge branch 'feature/pg_rewind' of https://github.com/zalando/patroni into feature/pg_rewind 2015-09-30 17:13:16 +02:00
Oleksii Kliukin 316e4f8d74 Merge branch 'master' into feature/pg_rewind 2015-09-30 17:12:03 +02:00
Oleksii Kliukin b4a2ed874f Merge branch 'master' of https://github.com/zalando/patroni 2015-09-30 16:47:07 +02:00
Oleksii Kliukin 182a90973d Make sure tests work with the new pytest. 2015-09-30 16:46:53 +02:00
Alexander Kukushkin 2fdf02e0be Merge pull request #55 from pgexperts/scripts/init-scripts
Added Upstart job for running patroni under Ubuntu 14.04 or 12.04.
2015-09-30 16:39:07 +02:00
Oleksii Kliukin a500781b6d Mock remove_data_directory in the pg_rewind test. 2015-09-30 16:32:56 +02:00
Josh Berkus c4cc0be4fe Added Upstart job for running patroni under Ubuntu 14.04 or 12.04. 2015-09-29 17:35:45 -07:00
Oleksii Kliukin e39d318732 Eliminate os.system call. 2015-09-28 12:04:06 +02:00
Oleksii Kliukin d44a54628a remove the data directory on an unsuccessfull rewind attempt. 2015-09-25 16:00:24 +02:00
Oleksii Kliukin b62d72a130 Merge branch 'master' into feature/pg_rewind 2015-09-25 13:08:42 +02:00
Oleksii Kliukin d6c8df45e1 Write the pg_rewind password in pgpass instead of passing it in the command line. 2015-09-25 13:08:12 +02:00
Oleksii Kliukin 36101974cf Merge pull request #49 from zalando/feature/bootstrap-from-main-loop
Run initial cluster bootstrap from the main loop
2015-09-24 15:04:52 +02:00
Oleksii Kliukin 027bcd39ce Move pg_rewind call into a separate sub.
Add a Postgresql method to call pg_rewind.
Improve the test coverage.
2015-09-24 12:46:36 +02:00
Oleksii Kliukin c8108f221e Check the exit code of the postgres start when determining whether to run the on_role_change callback. 2015-09-24 11:34:28 +02:00
Oleksii Kliukin 793325cb60 add support for pg_rewind. 2015-09-23 18:38:17 +02:00
Alexander Kukushkin a4266be3da remove unused function 2015-09-23 10:59:55 +02:00
Alexander Kukushkin e83651b57b Run initial cluster bootstrap from the main loop 2015-09-23 10:55:38 +02:00
Alexander Kukushkin 83c5416c82 Merge pull request #45 from zalando/feature/query-retry
Refactor Postgresql.query method to use common retry mechanism
2015-09-22 16:53:31 +02:00
Alexander Kukushkin d8e51f586f Merge branch 'feature/query-retry' of github.com:zalando/patroni into feature/query-retry 2015-09-20 13:58:12 +02:00
Alexander Kukushkin d8982e1e5a Refactor Postgresql.query method to use common retry mechanism
query method in an api.py also needs retry in some cases (for example
when we are running is_healthiest_node check).
In all cases we should retry only when connection is closed or broken.
BUT, the connection status must be checked via cursor.connection (old
implementation was using general connection object for that). For
multi-threaded applications this is not appropriate, because some other
thread might restore connection.

In addition to that I've changed most of the unit tests to use `Mock` and
`patch` where it is possible.
2015-09-20 13:54:30 +02:00
Alexander Kukushkin 9f9cb6005d Refactor Postgresql.query method to use commont retry mechanism
query method in an api.py also needs retry in some cases (for example
when we are running is_healthiest_node check).
In all cases We will retry only when connection is closed or broken, BUT
connection status must be checked via cursor.connection (old
implementation was using general connection object for that). For
multi-threaded applications this is not appropriate, because some other
thread might restore connection.

In appdition to that I've changed most of the unit tests to use `Mock` and
`patch` where it is possible.
2015-09-20 13:41:57 +02:00
Oleksii Kliukin 75be235d49 Merge pull request #40 from zalando/feature/ignore-second-sigterm
During shutdown sigterm is sent to all processes every second
2015-09-18 17:06:02 +02:00
Alexander Kukushkin 0a3a6d72cf Fix etcd unit tests 2015-09-18 15:33:58 +02:00
Alexander Kukushkin 9dfb562a4f wait for event on leader key a little bit longer than timeout 2015-09-18 15:29:50 +02:00
Alexander Kukushkin 3145e94797 check ignore_sigterm flag instead of setting new handler for SIGTERM 2015-09-18 15:27:09 +02:00
Alexander Kukushkin afe1a2c92c During shutdown sigterm is send to all processes every second
First time is triggers some shutdown mechanisms in a patroni, but the
second one just terminates patroni. Solution is pretty simple, we need
to ignore all other sigterms which are coming after the first one.
2015-09-18 12:41:36 +02:00
Alexander Kukushkin 8a0af6985f Merge pull request #35 from zalando/feature/basic-auth
Basic-auth and SSL support
2015-09-17 16:22:23 +02:00
Alexander Kukushkin 918ac6a87d Merge pull request #39 from zalando/feature/reschedule-next-run
Feature/reschedule next run of ha cycle depending on return value of `watch`
2015-09-17 16:22:12 +02:00
Alexander Kukushkin b9ccd411ed Merge pull request #19 from zalando/feature/faster_shutdown
Feature/faster shutdown
2015-09-17 16:21:59 +02:00
Alexander Kukushkin 6530e1f7aa Remove unused parameter in a is_leader method 2015-09-17 16:11:08 +02:00
Alexander Kukushkin 0b753d25e1 Get rid from is_promoted flag. use role == 'master' instead 2015-09-17 13:57:29 +02:00
Alexander Kukushkin dbcc5aff9b Track postgresql role in a Postgresql class 2015-09-16 16:22:10 +02:00
Alexander Kukushkin e204945b3d Merge branch 'master' of github.com:zalando/patroni into feature/faster_shutdown 2015-09-16 15:20:53 +02:00
Alexander Kukushkin 0435e36cad self.cluster = None if unexpected exception occured 2015-09-16 15:14:02 +02:00
Alexander Kukushkin 246f0dbbaf watch should return true if you are not leader 2015-09-16 14:23:47 +02:00
Alexander Kukushkin c240fd1ee8 More documentation for watch method 2015-09-16 11:09:53 +02:00
Alexander Kukushkin 7f8e95b334 Next run of ha cycle is rescheduled depending on return value of watch
Current etcd implementation does not yet support timeout option when
`wait=true`: https://github.com/coreos/etcd/issues/2468

Originaly I've implemented `watch` method for `Etcd` class in a
following manner: if the leader key was updated just because master
needs to update ttl and watch timeout is not yet expired, I was
recalculating timeout and starting `watch` call once again.
Usually after "restart" we were getting urllib3.exceptions.TimeoutError.
The only possible way to recover after such exception - close socket and
establish a new connection. With pure http it's relatively cheap, but
with https and some kind of authorization on etcd side it would became
rather expensive and should be avoided.
2015-09-16 10:38:34 +02:00
Alexander Kukushkin 01efcc8638 Merge branch 'master' of github.com:zalando/patroni into feature/basic-auth
Conflicts:
	tests/test_patroni.py
2015-09-15 09:33:18 +02:00
Alexander Kukushkin a8305079c3 Merge pull request #38 from zalando/bugfix/zookeeper
Bugfix/zookeeper
2015-09-15 09:29:18 +02:00
Alexander Kukushkin 90cfcf0c14 Make zookeeper module compatible with python3 2015-09-14 17:14:39 +02:00
Alexander Kukushkin 44a20f12a4 version field is znode is just version, not mzxid 2015-09-14 16:32:45 +02:00
Oleksii Kliukin bf5737614d Merge pull request #30 from zalando/feature/cleanup_on_failed_initialization
Make sure initialize flag is reset on failure.
v0.3
2015-09-14 12:57:39 +02:00
Oleksii Kliukin d69403ab6f Merge pull request #37 from zalando/feature/zookeeper-fetch-initialize
Build Cluster object for ZooKeeper the same way as for Etcd
2015-09-14 12:55:10 +02:00
Oleksii Kliukin 51eacc5042 Handle the case when initialize flag is not set and leader is present. 2015-09-14 12:36:28 +02:00
Alexander Kukushkin 98488a00a2 Remove unused import of KazooException 2015-09-14 12:00:24 +02:00
Alexander Kukushkin 4a081bcb71 Run cancel_initialization with retry 2015-09-14 11:58:10 +02:00
Alexander Kukushkin 209c985420 get_node and get_children should catch only NoNodeError exception.
All other exceptions are needed to have retry functionality working
correctly.
2015-09-14 11:45:00 +02:00
Alexander Kukushkin f494d2ce64 Build Cluster object for ZooKeeper the same way as for Etcd
Previous implementation was always setting Cluster.initialize to True.
Also it was throwing ZooKeeperError when there were no members in a
cluster.

Plus BUGFIX of a bug introduced with
https://github.com/zalando/patroni/pull/34 in a `load_members` method.
- data = self.get_node(self.member_path)
+ data = self.get_node(self.members_path + member)
It was always fetching the same node for all cluster members.
Fortunately Etcd doesn't have such problem because we are fetching the
whole cluster directory with one recursive API call.
2015-09-14 11:19:46 +02:00