Commit Graph
1198 Commits
Author SHA1 Message Date
Oleksii Kliukin 6eb2e21144 Add .zappr.yaml 2016-07-18 17:03:17 +02:00
Oleksii KliukinandGitHub 4f7a0e014b Merge pull request #227 from zalando/feature/scheduled_restarts
Implement scheduled restarts for Patroni via the API. 

Even normal (immediate) restarts will take advantage of additional modifiers you can supply to the restart endpoint:

- restart_pending: restart only if the pending restart flag is set (because of the configuration change)
- role: restart if the Postgres role is set to a certain value
- postgres_version (x.y.z) - restart if the current Postgres version is less than the one specified.

For the scheduled restart, the schedule parameter can be used the same way as it is currently used for the scheduled failovers. Particularly, we don't allow restarts in the past, and always require the timezone to be present in the request in order to avoid client/server TZ difference issues.

Unify the code that evaluates the schedule for the  scheduled restarts and scheduled failovers.
Use the RLock instead of Lock in the async_executor to avoid hanging if the thread takes the lock multiple times (mostly for the with blocks in the api).
2016-07-18 13:30:18 +02:00
Feike Steenbergen f7c44945b7 Fix > 9 PostgreSQL version numbering 2016-07-18 10:35:23 +02:00
Oleksii Kliukin 13b4306f40 Remove one more occurrence of the time bomb 2016-07-14 16:53:02 +02:00
Oleksii Kliukin 6c9ffa4d3c Address the code review
In particular, replace the fixed dates for the future actions
in the unit tests with those that depend on the current date,
avoiding the "timebomb" effect.
2016-07-14 16:39:35 +02:00
Oleksii Kliukin ffd27b5705 Rename with_pending_restart to restart_pending. 2016-07-13 11:07:37 +02:00
Oleksii Kliukin 3181c4e59f Code review, asynchronous restarts.
- Make the restart initiated by the schedule asynchronous
- Fix the placeholders in logs.
- Fix the regexp to detect the PostgreSQL version.
2016-07-12 20:25:01 +02:00
Oleksii Kliukin ec160f0d59 Do not send 2 quotes for the empty request, instead, send None. 2016-07-11 18:20:42 +02:00
Oleksii Kliukin bf95b75489 Use the parameter that really sets the pending_restart flag. 2016-07-11 18:20:15 +02:00
Oleksii KliukinandGitHub 405dbb1cbe Merge pull request #242 from zalando/feature/avoid_initial_wait_for_bootstrap
Set the initialize flag to None and not False initially.
2016-07-11 16:23:58 +02:00
Oleksii Kliukin 1412d16f6e Set the initialize flag to None and not False..
Initially, when the Patroni cluster key is not there, the etcd
and consul modules return an empty cluster value, with the
initialize flag set to False and not None. However, some checks
explictely verify that this flag is None, specifically, the one
that decides whether the new cluster should be bootstrapped.
This leads to the master waiting for the whole loop_wait before
running the initdb (and showing the "waiting for leader to bootstrap"
error): on the second loop_wait, the /service/cluster_name flag
is already there (because of the touch_member code).

Since I don't see where the initialize = False is explictely
differentiated from the None value, I think it makes sense to
set it to None uniformely; that's AFAIK always the case if you
use Zookeeper.
2016-07-11 15:44:20 +02:00
Oleksii Kliukin b17483b7dd Fix the PG version regex. 2016-07-11 15:21:31 +02:00
Oleksii Kliukin c91eda8d78 Merge branch 'master' into feature/scheduled_restarts 2016-07-11 12:56:24 +02:00
Oleksii Kliukin 6da2eecb90 Increase the test coverage. 2016-07-11 11:51:07 +03:00
Oleksii Kliukin 8548956370 Bumped version to 1.0 v1.0 2016-07-05 17:03:19 +02:00
Oleksii Kliukin 34d18cc182 Set the standard name for the docker-compose file. 2016-07-05 17:02:40 +02:00
Alexander KukushkinandGitHub 58ad8399cf Merge pull request #238 from zalando/bugfix/pg_rewind
One more try to fix pg_rewind
2016-07-05 16:25:03 +02:00
Alexander Kukushkin 659f7617f5 New option: remove_data_directory_on_rewind_failure
One more try to fix pg_rewind
2016-07-05 12:11:15 +02:00
Oleksii Kliukin 8834f929aa Improve the unit tests/coverage. 2016-07-05 10:07:29 +02:00
Oleksii Kliukin 36a86c67d0 Enable the conditions on normal restart. 2016-07-04 15:46:22 +02:00
Alexander KukushkinandGitHub a19dbfaddf Merge pull request #232 from zalando/bugfix/pg_rewind
Start readonly when holding leader lock
2016-07-04 13:11:35 +02:00
Alexander KukushkinandGitHub 40d48eae76 Merge pull request #237 from zalando/bugfix/etcd-retry
Calculate numer of retries and timeout
2016-07-04 13:11:25 +02:00
Alexander Kukushkin f7b9709907 Calculate numer of retries and timeout 2016-07-04 12:01:54 +02:00
Alexander Kukushkin 2944a4bcbd Start readonly when holding the leader lock 2016-07-04 11:08:24 +02:00
Alexander Kukushkin b84e22c4ea Implement more checks in the follow method
Although such situation should not happen in reality (follow method is
not supposed to be called when when the node is holding leader lock and
postgres is running), but to be on the safe side it is better to
implement as much checks as possible, because this method could
potentially remove data directory.
2016-07-04 10:56:37 +02:00
Alexander KukushkinandGitHub f9298d30ca Merge pull request #231 from zalando/bugfix/etcd-retry
Fix retry logic in etcd.py
2016-07-04 10:37:55 +02:00
Alexander KukushkinandGitHub e025f335dc Merge pull request #233 from zalando/bugfix/initialize
Initialize key can be present but empty
2016-07-04 09:48:09 +02:00
Alexander KukushkinandGitHub a6d840d6be Merge pull request #234 from zalando/feature/zookeeper-connect-strategy
Implement different connect strategy for zookeeper
2016-07-04 09:47:55 +02:00
Alexander KukushkinandGitHub cd752fea14 Merge pull request #235 from zalando/bugfix/docker-volumes
Volume could be passed to the docker only with absolute path
2016-07-04 09:47:35 +02:00
Alexander KukushkinandGitHub 3f1d06da32 Merge pull request #236 from zalando/bugfix/strtol
bugfix: strtol didn't worked correctly with 1 digit numbers
2016-07-04 09:47:09 +02:00
Alexander Kukushkin bc9aec9076 bugfix: strtol didn't worked correctly with 1 digit numbers 2016-07-01 16:19:57 +02:00
Alexander Kukushkin b7639f5b22 Volume could be passed to the docker only with absolute path
In addition to that add zookeeper support to the docker.
2016-07-01 12:43:33 +02:00
Alexander Kukushkin f7c6bd4eab Implement different connect strategy for zookeeper
Originally it was trying to connect during session_timeout time.
Such strategy doesn't work good during short network hiccups...
2016-07-01 12:31:29 +02:00
Alexander Kukushkin ee529669d2 Start readonly when holding leader lock
Not starting of postgres was causeing situation when there were no
master running...
2016-07-01 12:28:02 +02:00
Alexander Kukushkin 8bd071d9a9 Initialize key can be present but empty
Nodes were trying to grab initialize key when it didn't contained sysid
2016-07-01 12:25:00 +02:00
Alexander KukushkinandGitHub dc27a30800 Merge pull request #230 from zalando/bugfix/pg_rewind
Try to cover as much as possible pg_rewind corner-cases
2016-06-30 12:09:10 +02:00
Alexander KukushkinandGitHub 489ed20331 Merge pull request #229 from zalando/bugfix/env-zookeeper-hosts
Document that every single zookeeper host:port MUST be quoted
2016-06-30 12:09:03 +02:00
Alexander Kukushkin aa10f42913 checkpoint method returns string status message 2016-06-30 10:45:54 +02:00
Feike Steenbergen 72f8fcbb5b Document the per node timeout 2016-06-29 16:40:39 +02:00
Alexander Kukushkin 876cfdfb2d Fix retry logic in etcd.py
Client class takes care about retrying when connection to the etcd node
fails. It calculates amount of retries and timeout depending on etcd
cluster size.

Etcd class should not retry when EtcdConnectionFailed exception is
raised (this case is already handled in the Client).

Besides that adjust retry timeouts in the Client class.
2016-06-29 15:30:54 +02:00
Alexander Kukushkin 4b67008488 Try to cover as much as possible pg_rewind corner-cases
rewind is not possible when:
1) trying to rewind from themself
2) leader is not reachable
3) leader is_in_recovery

All these cases were leading to removing of data directory...
In all cases except 1) it should "retry" when leader will became
available and not is_in_recovery.
2016-06-29 14:29:31 +02:00
Alexander Kukushkin ae88e7c96e Document that every single zookeeper host:port MUST be quoted
otherwise yaml library can not parse the list.
And make visible yaml exception when trying to parse this list.
2016-06-29 14:25:50 +02:00
Oleksii Kliukin 7a1e2e0c72 Fix the assert message. 2016-06-28 17:11:13 +02:00
Oleksii Kliukin d2832ee43b Address the code review.
Fix return  value in the should_run_scheduled_action and the comments.
Correct the json composition in the scheduled_restart test.
Fix the delete in case there is no scheduled restart.
Fix the usage of format in the logger output.
Fix the indentation in the evaluate_scheduled_restart.
Fix the condition related to the body_is_optional in the do_POST_restart.
Fix a few typos in the error messages.
Fix the _read_json_content
Make the scheduled restart unit-tests a bit less ugly
2016-06-28 16:54:20 +02:00
Alexander KukushkinandGitHub 0c6a1307da Merge pull request #228 from zalando/bugfix/always-expose-role
bugfix: api must report role=master during pg_ctl stop
2016-06-28 15:24:16 +02:00
Alexander KukushkinandGitHub cae3b8ec1e Merge pull request #226 from zalando/bugfix/sigterm
Setup signal handler before creating dcs
2016-06-28 15:24:05 +02:00
Alexander KukushkinandGitHub 6fdd01a8eb Merge pull request #225 from zalando/feature/confd
sample haproxy templates for confd
2016-06-28 15:23:54 +02:00
Alexander KukushkinandGitHub fe0bc2f3eb Merge pull request #223 from zalando/feature/patronictl-at
Acceptance tests for patronictl
2016-06-28 15:23:44 +02:00
Alexander Kukushkin 0318749b56 bugfix: api must report role=master during pg_ctl stop
In addition for that make pg_ctl --timeout option configurable.
If the stop or start didn't succeeded during given timeout when demoting
master, role will be forcibly changed to 'unknown' and all needed
callbacks executed.
2016-06-28 14:14:42 +02:00
Oleksii Kliukin 854ff27e56 Allow normal conditional restarts.
In addition, use the RLock instead of the Lock in async executor
to make sure the lock can be acquired more than once from a single
thread.
2016-06-27 09:50:09 +02:00