Commit Graph
100 Commits
Author SHA1 Message Date
Alexander Kukushkin 2086c90a4a Try to get rid from hardcoded names when building binary 2016-09-05 14:11:53 +02:00
Alexander Kukushkin 5c7efa3a65 Update gitignore 2016-09-05 14:10:21 +02:00
Alexander Kukushkin 74166e996c Fix tests and formatting 2016-08-25 10:09:32 +02:00
Alexander Kukushkin 9bb07fb419 Merge branch 'master' of github.com:zalando/patroni into feature/replica-info 2016-08-25 10:09:06 +02:00
Alexander Kukushkin 1dc16fc12b Travis changed python version to 3.5.2
Plus stick to the flake8==2.6.0 until
https://gitlab.com/pycqa/flake8/issues/164 is not fixed
2016-08-01 09:19:19 +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
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 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 Kukushkin aa10f42913 checkpoint method returns string status message 2016-06-30 10:45:54 +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
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
Alexander Kukushkin 44433c2d42 Setup signal handler before creating dcs
Otherwise it was swallowing SysExit exception in an infinite loop.
2016-06-22 09:13:47 +02:00
Alexander Kukushkin d65d1028a7 Add patroni-compose-etcd-3.yml
For starting up cluster easy with docker-compose.
And unify Dockerfile and scripts to be able to work with docker-compose
and the old one dev_patroni_cluster.sh script
2016-06-21 17:07:24 +02:00
Alexander Kukushkin fa01cc828a No need to create symlink for patroni.py 2016-06-17 12:59:12 +02:00
Alexander Kukushkin 5683880de6 bugfix: old mock module does not mock open properly 2016-06-17 12:51:09 +02:00
Alexander Kukushkin ba2c0627be Merge branch 'master' of github.com:zalando/patroni into feature/confd 2016-06-17 12:21:13 +02:00
Alexander Kukushkin e09a012016 extend list of keywords 2016-06-17 12:20:20 +02:00
Alexander Kukushkin bd1e658080 Bugfix: obviously sys.hexversion was one symbol shorter
plus remove some unneeded code
2016-06-17 12:18:41 +02:00
Alexander Kukushkin 23e0eb0aa7 Fix flake8 check with python3 2016-06-17 11:52:47 +02:00
Alexander Kukushkin 50e269470e Add haproxy and confd to docker image
and start them on the node where etcd is running
2016-06-17 11:51:37 +02:00
Alexander Kukushkin 4fbdd3f8a0 Add haproxy confd templates 2016-06-17 11:51:05 +02:00
Alexander Kukushkin 27bdc65e46 Fix acceptance tests with python3 2016-06-16 15:27:41 +02:00
Alexander Kukushkin bd5440a102 Fix a typo and call sys.exit on sigterm
otherwise it will wait up to `loop_wait` seconds berfore exiting...
2016-06-16 15:19:21 +02:00
Alexander Kukushkin fcde17583c Acceptance tests for patronictl
Call patronictl.py when it's possible instead of doing REST API calls.
2016-06-16 15:06:18 +02:00
Alexander Kukushkin 69099b060e SystemExit exception was swallowed in in thread
It was causing patroni failing to stop after receiving SIGTERM.
Acceptance tests was killing it with SIGKILL which was causing further tests fail because postgres was still running:
2016-06-16 14:36:24,444 INFO: no action.  i am the leader with the lock
2016-06-16 14:36:25,448 INFO: Lock owner: postgres0; I am postgres0
2016-06-16 14:36:25,452 ERROR: Failed to update /service/batman/optime/leader
Traceback (most recent call last):
  File "/home/akukushkin/git/patroni/patroni/dcs/zookeeper.py", line 208, in write_leader_optime
    self._client.retry(self._client.set, path, last_operation)
  File "/home/akukushkin/git/patroni/py2/local/lib/python2.7/site-packages/kazoo/client.py", line 273, in _retry
    return self._retry.copy()(*args, **kwargs)
  File "/home/akukushkin/git/patroni/py2/local/lib/python2.7/site-packages/kazoo/retry.py", line 123, in __call__
    return func(*args, **kwargs)
  File "/home/akukushkin/git/patroni/py2/local/lib/python2.7/site-packages/kazoo/client.py", line 1219, in set
    return self.set_async(path, value, version).get()
  File "/home/akukushkin/git/patroni/py2/local/lib/python2.7/site-packages/kazoo/handlers/utils.py", line 74, in get
    self._condition.wait(timeout)
  File "/usr/lib/python2.7/threading.py", line 340, in wait
    waiter.acquire()
  File "/home/akukushkin/git/patroni/patroni/utils.py", line 219, in sigterm_handler
    sys.exit()
SystemExit
2016-06-16 14:36:25,453 INFO: no action.  i am the leader with the lock
2016-06-16 14:36:26,443 INFO: Lock owner: postgres0; I am postgres0
2016-06-16 14:36:26,444 INFO: no action.  i am the leader with the lock
2016-06-16 14:59:13 +02:00
Alexander Kukushkin 9f5276dd2b patronictl will send authorization header if it is configured
username:password can be configured in the 'restapi' section of config
file or via environment
2016-06-16 12:16:16 +02:00
Alexander Kukushkin fe3a999cb2 Enforce name requirements for dcs implementations
Class implementing AbstractDCS must have name similar to the module
name. I.e. Patroni will load ZooKeeper from zookeeper.py, but not from
exhibitor.py, although it (ZooKeeper) is also available there.
2016-06-16 11:32:16 +02:00
Alexander Kukushkin bd6070e2b0 Make patronictl use config.py for loading config_file
config.py is not only loading config_file but also can build
configuration from environment variables.
2016-06-16 08:50:44 +02:00
Alexander Kukushkin c1b6f1ef24 Make list of available dcs implementations unique.
And exclude AbstractDCS from it.
2016-06-16 08:48:49 +02:00
Alexander Kukushkin 6cf63d1366 Implement copy method
It returns copy of `effective_configuration`.
Don't check that PATRONI_*_USERNAME and PATRONI_*_PASSWORD are set
together. User may want to set only PASSWORD.
2016-06-16 08:45:52 +02:00
Alexander Kukushkin 57807ff337 Don't expose replication user/passwd in DCS 2016-06-15 09:34:04 +02:00
Alexander Kukushkin 25f20ca7d7 Fix documentation 2016-06-14 10:13:47 +02:00
Alexander Kukushkin 3ff1106526 Reset restart_pending flag when parameter was set to the old value
but restart didn't happened.
And small bugfix: node can't rewind from themself.
2016-06-13 14:11:35 +02:00
Alexander Kukushkin a24b29deec use_slots can be changed only globally 2016-06-13 12:54:33 +02:00
Alexander Kukushkin 8829ef6bab Make QuantifiedCode happy 2016-06-13 10:55:15 +02:00
Alexander Kukushkin c64170ef33 Extend list of postgres parameters controlled by Patroni
These parameters usually must be the same across all cluster nodes and
therefore must be set only via global configuration and always passed as
a list of postgres arguments (via pg_ctl) to make it not possible
accidentally change them by 'ALTER SYSTEM'
2016-06-13 10:33:14 +02:00
Alexander Kukushkin e373a1e0bb Hexadecimal can be written as 0X 2016-06-13 10:32:54 +02:00
Alexander Kukushkin 9ecff0f64d Bugfixes
* GET /config was returning latesy "correct" version of dynamic
  configuration.
* PATCH /config was breaking when trying to patch not dict with dict
2016-06-10 12:35:04 +02:00
Alexander Kukushkin 19037daa05 Merge branch 'feature/dynamic-configuration' of github.com:zalando/patroni into feature/environment-configuration 2016-06-10 12:30:37 +02:00
Alexander Kukushkin 95db7259d4 Implement strtol as close as possible to stdlib.strtol 2016-06-10 08:43:08 +02:00
Alexander Kukushkin 49efb371f9 Make it possible to work without config.yml
Most of the basic configuration could be done via ENV
2016-06-09 14:44:29 +02:00
Alexander Kukushkin 7244739e26 Fix link to the libpq-pgpass.html 2016-06-09 12:10:37 +02:00
Alexander Kukushkin e9be5e8462 Configure exhibitor port via ENV 2016-06-09 11:40:10 +02:00
Alexander Kukushkin 4edac15dce Merge branch 'feature/dynamic-configuration' of github.com:zalando/patroni into feature/environment-configuration 2016-06-09 11:24:20 +02:00
Alexander Kukushkin f576311532 Add special treatment for zookeeper.exhibitor section 2016-06-09 11:19:31 +02:00
Alexander Kukushkin 5314433b70 Merge branch 'feature/dynamic-configuration' of github.com:zalando/patroni into feature/environment-configuration 2016-06-09 11:09:30 +02:00
Alexander Kukushkin ce4d814819 Merge branch 'feature/dynamic-configuration' of github.com:zalando/patroni into feature/dynamic-configuration 2016-06-09 11:05:17 +02:00
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 57c6641683 Reimplement pg_ctl status in python
subprocess.call was causing problems when server is running under high
load.
2016-06-09 08:28:11 +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 23c5040ce5 Update documentation 2016-06-08 12:35:53 +02:00
Alexander Kukushkin efe45bac63 Merge branch 'feature/environment-configuration' of github.com:zalando/patroni into feature/environment-configuration 2016-06-08 10:32:15 +02:00
Alexander Kukushkin f2fc68acde Fix pep8 formatting 2016-06-08 10:31:59 +02:00
Alexander Kukushkin b7d87f7d07 Implement possibility to configure Patroni via environment 2016-06-08 10:15:24 +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