Commit Graph
100 Commits
Author SHA1 Message Date
Alexander Kukushkin 5f4e582660 Merge branch 'master' of github.com:zalando/patroni into feature/dynamic-configuration 2016-06-09 11:04:28 +02:00
Alexander Kukushkin 50d118c3aa Split ZooKeeper and Exhibitor
Originally Exhibitor was supported in the ZooKeeper class and
configuration for Exhibitor was taken also from `zookeeper` section in
the yaml config file. In fact, Exhibitor just extends ZooKeeper and now
it is reflected in the code and also Exhibitor got it's own section in
the config.yaml file. It will make it easier to configure Exhibitor
hosts and port via environment variables when PR#211 will be merged.
2016-06-08 19:21:18 +02:00
Alexander Kukushkin 53891ee98e Merge branch 'master' of github.com:zalando/patroni into feature/dynamic-configuration 2016-06-06 10:50:49 +02:00
Alexander Kukushkin 24822bd9ac Returning 304 for POST, PATCH, PUT is not good idea 2016-06-06 10:50:42 +02:00
Alexander Kukushkin 40529d718c Get rid from unused variable 2016-06-03 12:28:31 +02:00
Alexander Kukushkin 16771f37d5 Compare old and new user-defined-parameters to avoid reload
when parameters didn't changed.
Plus get wal_segment_size from pg_settings instead of hardcoding it's value.
2016-06-03 12:11:14 +02:00
Alexander Kukushkin d536b4b62a Rollback changes regarding config_file
It could be set only on the postgres command line anyway.
2016-06-02 16:45:17 +02:00
Alexander Kukushkin 2e5ce4a303 "Smart" compare of postgres parameters
to decide do we need to reload/restart
2016-06-02 16:34:34 +02:00
Alexander Kukushkin ebb9e252d8 Rename restart_pending to pending_restart for compatibility 2016-06-02 09:31:30 +02:00
Alexander Kukushkin 2d78ef0922 CREATE/ALTER USER=>ROLE 2016-06-02 09:28:11 +02:00
Alexander Kukushkin 1c30948ef9 Implement PUT /config and enhance some checks 2016-06-01 17:06:31 +02:00
Alexander Kukushkin c8b5003b86 Set __do_not_watch flag when ttl needs to be changed
it's more readable comparing to `reset_cluster`
2016-06-01 13:41:49 +02:00
Alexander Kukushkin aad2433440 Make QuantifiedCode happier 2016-06-01 10:04:50 +02:00
Alexander Kukushkin 140917ba37 Fix a typo 2016-06-01 09:27:00 +02:00
Alexander Kukushkin 60f7759c5e Small optimization
Don't compare values of configuration if modify_index didn't changed
2016-06-01 09:21:42 +02:00
Alexander Kukushkin a55cbff865 Compare configuration objects "smart" and "deep" 2016-05-31 16:16:29 +02:00
Alexander Kukushkin 1c2e1755cb Explicitly cast some parameters from DCS to int (ttl, loop_wait, etc...) 2016-05-31 15:51:49 +02:00
Alexander Kukushkin e10873dd9c RestApiHandler._patch_config returns True if configuration was changed 2016-05-31 15:49:55 +02:00
Alexander Kukushkin 1cd42d4e47 Get rid from some stupid logic with options=True/False
And some other tricks with overriding handle_one_request and finish
methods from the parent class which were necessary only to make OPTIONS
request from haproxy work with python2, but in fact it was still not
working with python3. Instead of doing all the magic we should simply
give to haproxy what it wants to get: HTTP response code and nothing
more.
2016-05-31 14:42:00 +02:00
Alexander Kukushkin d47671e5b6 ALTER USER does not add LOGIN to the non-login role 2016-05-31 13:18:18 +02:00
Alexander Kukushkin a40377fac1 rename options to only_status_code 2016-05-31 10:34:21 +02:00
Alexander Kukushkin b3ada161cf Implement possibility to configure retry_timeout globally
Previously it was hardcoded all over the place.
2016-05-31 10:30:53 +02:00
Alexander Kukushkin 515e9e34f4 Update SETTINGS.rst accordingly to the new config 2016-05-31 08:58:21 +02:00
Alexander Kukushkin 25f4f943ae Merge branch 'master' of github.com:zalando/patroni into feature/dynamic-configuration 2016-05-31 08:22:07 +02:00
Alexander Kukushkin 9379c036d5 Add comments to set_ttl method
To explain how it's supposed to work and why it manupulates with the
cache of `Cluster` object (calls `reset_cluster`)
2016-05-30 17:02:29 +02:00
Alexander Kukushkin b7359e7b0d Rollback all changes to basic_replication.feature
since I moved all functionality to patroni_api.feature
2016-05-30 12:40:52 +02:00
Alexander Kukushkin f7912991a8 Reshuffle acceptance tests one more time 2016-05-30 12:37:14 +02:00
Alexander Kukushkin 33b6c88fd5 state_handler.follow needs to know cluster.leader 2016-05-30 11:59:58 +02:00
Alexander Kukushkin e085c866dc Reshuffle acceptance tests
Move dynamic config tests from basic_replication to patroni_api
2016-05-30 11:30:41 +02:00
Alexander Kukushkin dd70a3f325 BUGFIX: demote is already running in a thread
It should not call `recover` but `state_handler.follow` directly
(like it is already done in the `clone`).
Otherwise it tries to create a new thread and all async functionality
became borken...
2016-05-30 11:06:16 +02:00
Alexander Kukushkin 8b5d6e83e7 fix some bugs revaled by acceptance tests 2016-05-27 17:38:19 +02:00
Alexander Kukushkin 073ef3784f Implement PATCH /config 2016-05-27 16:29:33 +02:00
Alexander Kukushkin 6700cd0aa6 Implement reload of config.yml with REST API call
and acceptance tests for that
2016-05-26 17:09:40 +02:00
Alexander Kukushkin 7fec42c12f Remove password from backup connection string
It's written into pgpass file anyway and ENV variable is set.
2016-05-26 12:01:28 +02:00
Alexander Kukushkin 45cbc8ca70 Implement acceptance test for dynamic configuration functionality
and fix some bugs revealed by acceptance tests
2016-05-26 10:16:24 +02:00
Alexander Kukushkin 89adc0717a Set loglevel back to INFO 2016-05-25 15:02:42 +02:00
Alexander Kukushkin ceace03646 Address codacy and travis issues 2016-05-25 14:49:33 +02:00
Alexander Kukushkin 7827951c8c Dynamic configuration 2016-05-25 14:17:05 +02:00
Alexander Kukushkin 6104d688d9 Merge branch 'master' of github.com:zalando/patroni into feature/sighup 2016-05-19 14:27:04 +02:00
Alexander Kukushkin 6a4793bba8 Find and load dcs class implementation dynamically 2016-05-19 12:42:19 +02:00
Alexander Kukushkin 0c2aad98a3 Move dcs implementations into dcs package 2016-05-19 10:57:18 +02:00
Alexander Kukushkin 1741fa7e0f Mininize number of references to dcs implementations from tests
where it is not necessary (test_ha, test_ctl, etc...)
It will simplyfy further refactoring and make it possible to install
implementations of AbstractDCS independant of each other.
2016-05-19 10:00:32 +02:00
Alexander Kukushkin 98c505a16b Remove unused argument 2016-05-13 16:12:46 +02:00
Alexander Kukushkin d422e16aad Implement reload of config.yaml on SIGHUP
If some changes require restart of postgres patroni will expose
`restart_pending` flag in DCS and via REST API
2016-05-13 13:31:21 +02:00
Alexander Kukushkin 45a52e21f0 Write postgres options to postgresql.conf
Originally we were passing postgresql options as an argument of `pg_ctl
start`. It was nice and convenient because doesn't require to touch
configuration files but this method has one significant drawback: it
wasn't possible to change values of options which were passed as an
arguments without restart (event for the case when option reqires only
reload). Instead of doing that (passing options as arguments) we will:
1) rename original postgresql.conf to postgresql-base.conf
2) write options into postgresql.conf which has `include
  'postgresql-base.conf'` on the the third line after comment that this
  file is generated by Patroni and you should not change it manually
3) listen_addresses and port are still passed as an arguments to the
  pg_ctl (just to be foolproof against ALTER SYSTEM set port to 'random')

In addition to that this commit makes some attributes of `Postgresql`
class private (prefixes them with _)
2016-05-13 12:40:04 +02:00
Alexander Kukushkin d316a08c26 Merge branch 'master' of github.com:zalando/patroni into bugfix/do-not-remove-data 2016-05-10 13:14:58 +02:00
Alexander Kukushkin 36d187ee1f Remove data directory only if replica creation failed
And follow the right node after replica creation (it was following
the same node from which it took the backup)
2016-05-10 10:59:26 +02:00
Alexander Kukushkin edf372e8b6 Reset _sysid and don't call pg_controldata when restore of backup in progress
Otherwise there were some errors in a log from rest-api healthcheck endpoint
2016-05-09 15:36:49 +02:00
Alexander Kukushkin 73119f96aa Set application_name to node name in primary_conninfo
It will make it simplier to identify node the in pg_stat_replication view
2016-05-09 09:47:32 +02:00
Alexander Kukushkin defc987328 Encode request body only once in a MockRequest
to avoid using bytestrings all over the file
2016-05-09 09:33:54 +02:00
Alexander Kukushkin 2adf593fb8 finish method does not have any arguments 2016-05-09 09:31:29 +02:00
Alexander Kukushkin eabfd82a5d Implement Consul support 2016-04-27 10:59:01 +02:00
Alexander Kukushkin bcbc080350 urllib3.exceptions.HTTPError fixes for python 3.5.1
Somehow when you import only urllib3 it's not possible work with
urllib3.exceptions.HTTPError exception (it looks like it is imported
from some other place. from urllib3.exceptions import HTTPError solves
the problem.
2016-04-24 14:18:34 +02:00
Alexander Kukushkin a18c878a56 Rename me->member (variable name was too confusing) 2016-04-22 15:28:41 +02:00
Alexander Kukushkin 84fcc7712b Refactor api.py
All responses to the client sent by single method `_write_response`
encode('utf-8') is done only inside this method. It make easier to
support existing code because eliminates need to put b'' everywhere
2016-04-22 10:38:23 +02:00
Alexander Kukushkin 499061918d Implement noloadbalance support
Mostly this tag is necessary to give a hint to load balancer
auto-configuration tool that node should not be included into
LB configuration.
In addition to that Patroni also should not return status_code=200
for a health check if the tag is present and value is not `False`.
2016-04-22 09:46:34 +02:00
Alexander Kukushkin fd4f12aac8 Do not assume that connection user is postgres, but take it from config.yml 2016-04-21 13:56:09 +02:00
Alexander Kukushkin 122895e1d6 Append values from postgresql.recovery_conf to recovery.conf
Previously these values were appended only when the leader was known and
it was preventing replica from restoring xlogs with `restore_command`.
2016-04-20 15:56:33 +02:00
Alexander Kukushkin e4005ac76c Join multiline string with \n 2016-04-19 10:30:04 +02:00
Alexander Kukushkin cd6537c4d3 Refactor patroni/ctl.py
Until now get_dcs method was doing absolutely the same job as method
from Patroni class.
In addition to that I did small refactoring and clean up of unit tests
2016-04-18 17:36:30 +02:00
Alexander Kukushkin 6dc4aacf05 Add some comments to .travis.yml 2016-04-14 13:06:42 +02:00
Alexander Kukushkin 7006a4ee14 Sometimes replica can't attach to the master after pg_rewind
The reason for that is: it takes up to 10 seconds to create replication
slot + up to 5 seconds to start straming and recover.
2016-04-13 14:28:00 +02:00
Alexander Kukushkin d57310bbc0 Fix one more corner-case
It could take up to 10 seconds to create replication slot.
In addition to that when replica fails to connect to the master via
streaming replication it doesn't retry immediately, but with some
timeout (5 seconds). 10 + 5 == 15 what causes replication check
scenarios fail.
2016-04-13 14:09:45 +02:00
Alexander Kukushkin 946d8ef4f2 Do not try to query xlog_location when async_executor is busy 2016-04-13 13:32:39 +02:00
Alexander Kukushkin 01da5266a0 Give time for running healh-checks when promoting replica 2016-04-13 13:32:39 +02:00
Alexander Kukushkin 0ebfb30192 break on test failure 2016-04-13 13:32:39 +02:00
Alexander Kukushkin b4e86f0809 Make it possible to schedule failover in less then 10 seconds
But only when API request was posted to the leader
2016-04-13 13:32:39 +02:00
Alexander Kukushkin 94331fde6d Do not try to fetch xlog_location when async_executor is busy 2016-04-13 13:32:39 +02:00
Alexander Kukushkin ff41818a84 Make unit-tests output less verbose
It will capture output to stdout and stderr and print it when test is
failed. Please set LOGLEVEL env variable to INFO or DEBUG if you want
to see everything (as it was before).
2016-04-13 13:32:39 +02:00
Alexander Kukushkin 15d30a2d35 Try to stabilize acceptance tests 2016-04-13 13:32:39 +02:00
Alexander Kukushkin f8bf1bb0ab Disable sudo, reshuffle travis tasks and introduce caching
Without sudo travis is executing build tasks using docker and waiting
time in this case is really small, usually not longer then 10 seconds.

postgresql-9.5 is installed via addons.apt.packages (without sudo)
But ports 5432 and 5433 are busy. So I had to ajust environment.py to
assign port from higher diapason.

And a few words about build tasks:
First task is used for executing unit tests for all different python versions
The second one is used for executing acceptance tests against etcd
The third one is used for executing acceptance tests against zookeeper
acceptance tests are executed with python2.7 and python3.5

In addition that I've introduced caching of python virtual environment.
It really helps to reduce time needed to install python modules.
2016-04-13 13:32:39 +02:00
Alexander Kukushkin d7d69af12f In some cases output_members function was showing cluster=None 2016-04-08 16:50:22 +02:00
Alexander Kukushkin ada50e418c Update scenario description 2016-03-31 17:13:29 +02:00
Alexander Kukushkin 7c683336fb Don't expose empty tags dict in API and DCS 2016-03-30 15:16:57 +02:00
Alexander Kukushkin 24cc93ac70 Don't expose known boolean tags with value not True 2016-03-30 15:00:25 +02:00
Alexander Kukushkin db5999a639 Correct implementation of 'clonefrom' feature
According to https://github.com/zalando/patroni/issues/48 'clonefrom'
tag should be boolean and it should be used to mark node as a suitable
for creation of a new replica from. If there are more then one such node
in the cluster (with tag clonefrom=true), one of them will be chosed
randomly.
2016-03-30 11:30:05 +02:00
Alexander Kukushkin 0469d4374d Set metaclass of AbstractDCS with six to be python 2&3 compatible 2016-03-24 17:07:56 +01:00
Alexander Kukushkin d4cb15179f Return "demote reason" more precise depending on cluster state 2016-03-24 14:52:27 +01:00
Alexander Kukushkin 9c41ce9f1c We should run checkpoint before shutdown all the time except one case
(when patroni is being shutdown)
2016-03-24 14:50:34 +01:00
Alexander Kukushkin e6af18f0bb Former leader was not able to reattach to cluster without pg_rewind
It was shutdown correctly and I expected such 'join' working, but it was
not, because new leader didn't had enough time to catch up with the
master before promote.
2016-03-24 14:45:21 +01:00
Alexander Kukushkin 9dc588231f Speed up reattach of former leader to the cluster
Instead of starting it up in "read-only", it wil wait 2 seconds, to give
a time to somebody to prompte and after it will execute normal `recover`
procedure.
2016-03-24 12:29:30 +01:00
Alexander Kukushkin 0d3dca56ff In some cases Ha.cluster can be None after calling get_cluster
Such situation is causing patroni crash. Usually it was happening during
manual failover, after former master has demoted and `reset_cluster`
method has been called. In this case `fetch_cluster` was `False` and
`_load_cluster` method was returning value from `self._cluster`, which
was `None`.
2016-03-24 12:06:39 +01:00
Alexander Kukushkin 3a7d2c3874 Remove unused code from unit tests 2016-03-21 20:48:17 +01:00
Alexander Kukushkin 54055c1ff8 Rename ambiguous Failover.member to candidate
But! 'member' is still accepted by REST API and also name 'member' is
used to strore/read this value to/from DCS (for backward comatibility)
2016-03-18 15:59:47 +01:00
Alexander Kukushkin ca3414bda0 Ha loop was writing into scheduled_at during "manual_failover" 2016-03-18 13:24:30 +01:00
Alexander Kukushkin 8a7d2b53e0 Add forgotten mock to the test_ha.py 2016-03-15 16:40:55 +01:00
Alexander Kukushkin 0e0c8ed8d7 Implement delete_cluster interface in for all available dcs
In addition to that rename confusing `Etcd.client` and
`ZooKeeper.client` into `_client`. This attribute is available from
AbstractDCS and people had wrong impression that it provides the same
interface for different DCS implementations, which is obviously not the
case. For Etcd it has type etcd.Client and for ZooKeeper - KazooClient.
2016-03-15 16:25:48 +01:00
Alexander Kukushkin ffebfd84fd Merge branch 'master' of github.com:zalando/patroni into feature/acceptance_tests_behave 2016-03-14 11:54:44 +01:00
Alexander Kukushkin 7d4ec19bca Enable etcd cluster id check 2016-03-14 10:51:50 +01:00
Alexander Kukushkin 3319c3eeea replace unused variables with _ 2016-03-11 15:36:24 +01:00
Alexander Kukushkin ba444adb67 make codacy and quantifiedcode happier 2016-03-11 15:32:16 +01:00
Alexander Kukushkin d3c2b8b2aa replace unused variables with _ 2016-03-11 15:18:58 +01:00
Alexander Kukushkin ea59692b82 Merge branch 'master' of github.com:zalando/patroni into feature/remove-unused-code 2016-03-11 15:15:13 +01:00
Alexander Kukushkin 5f6beae22f Enforce data-type checks for step matcher
and increase default timeout for patroni start
2016-03-11 14:46:14 +01:00
Alexander Kukushkin 8b81d270bc BUGFIX: Assertion Failed: Steps must be unicode 2016-03-11 13:47:57 +01:00
Alexander Kukushkin 30d3982d25 Acceptance tests with behave 2016-03-11 12:56:29 +01:00
Alexander Kukushkin ad7910c025 Merge branch 'feature/acceptance_tests' of github.com:zalando/patroni into feature/acceptance_tests_travis 2016-03-11 09:04:08 +01:00
Alexander Kukushkin 33a1de7828 Fix .travis.yml 2016-03-10 17:23:44 +01:00
Alexander Kukushkin c2d1eea7d0 disable clonefrom test 2016-03-10 17:19:43 +01:00
Alexander Kukushkin 42d798a3de acceptance tests on travis 2016-03-10 17:19:10 +01:00