Commit Graph
100 Commits
Author SHA1 Message Date
Oleksii Kliukin 8548956370 Bumped version to 1.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
Oleksii Kliukin 95efd72679 Make container name predictable. 2016-06-17 16:37:28 +02:00
Oleksii Kliukin 9e6ca617de Add spec for the dynamic configuration. 2016-05-11 09:48:54 +02:00
Oleksii Kliukin e839386283 Remove the comment that is oudated since the bootstrap separation from the create replica. 2016-05-10 12:56:36 +02:00
Oleksii Kliukin f801a08974 Bumped version to 0.90 2016-04-27 12:04:52 +02:00
Oleksii Kliukin a07b015679 Move the recovery.conf based role check to a function. 2016-04-15 17:32:29 +02:00
Oleksii Kliukin c15c13876a HA tests assume the default role as replica. 2016-04-15 10:08:31 +02:00
Oleksii Kliukin 0de3a6ece4 Try to guess the postgres role before it is started by examinging the recovery.conf. 2016-04-15 09:34:34 +02:00
Oleksii Kliukin 309b5d4803 Remove restrictions on running pg_rewind.
Previously, pg_rewind was called only if a crashed master tried
to rejoin the cluster. It didn't cover the important case of a
master shut down cleanly, but with a combination of a smart
shutdown and subsequently a fast shutdown. Since out pg_rewind
code does not depend on the "uncleanness" of the master's shutdown,
we can call it unconditionally in all cases where the former master
tries to rejoin as a replica.

This resolves  #167.
2016-04-11 17:56:18 +02:00
Oleksii Kliukin 4ad190549a Fix a typo in the help message. 2016-04-04 12:33:05 +02:00
Oleksii Kliukin 60e6ed67e3 Add unit tests. 2016-04-04 10:06:28 +02:00
Oleksii Kliukin 9744019341 Read Patroni configuration from the environment.
The environment variable name is PATRONI_CONFIGURATION.
If both the filename and the variable supplied, the file takes priority.
2016-04-04 09:40:30 +02:00
Oleksii Kliukin 699b53964e Make sure present but empty optional sections don't cause errors. 2016-03-24 10:48:29 +01:00
Oleksii Kliukin 3fdf249f4b Bumped version to 0.80 2016-03-14 16:02:49 +01:00
Oleksii Kliukin 75d196a1f4 Update the TODO list. 2016-03-14 15:57:34 +01:00
Oleksii Kliukin 6985df3aca Restore the test for the clone from the replica. 2016-03-11 16:59:35 +01:00
Oleksii Kliukin 59836f8775 Merge branch 'master' of https://github.com/zalando/patroni into feature/acceptance_tests_behave 2016-03-11 16:58:56 +01:00
Oleksii Kliukin 6c63d32253 zappr config must be .yml. 2016-03-11 16:39:57 +01:00
Oleksii Kliukin 9ca1b754a5 Add zappr configuration. 2016-03-11 16:33:26 +01:00
Oleksii Kliukin d965d21ada Unit-tests for clone from the replica.
Remove clonefrom function from dcs, since it's not used.
2016-03-11 10:48:58 +01:00
Oleksii Kliukin 805716ed68 Variables and parameters renaming.
Previously, "without_leader" suffix was used in the name of methods
and functions that initialize a replica without an active replication
connection, and leader was part of the name for parameters and messages
that require an active replication conneciton. Since we support init
from the members other than the leader, those conventions have to be
changed.
2016-03-11 10:19:00 +01:00
Oleksii Kliukin 9057ddeb7c First implementation of cloning from the replica.
At the moment we just replace the master with the
node at the 'clonefrom' tag if it's present. Master
should be available anyway, otherwise, it will not
even try to do cloning.

Acceptance tests:
https://github.com/zalando/patroni/pull/144/commits
2016-03-10 16:06:31 +01:00
Oleksii Kliukin 998f0da3d8 Add cascading replication (backup from the replica) tests. 2016-03-10 16:05:06 +01:00
Oleksii Kliukin ede5661da3 Remove hard-coded values from the failover code. 2016-03-04 19:21:48 +01:00
Oleksii Kliukin aa844b63d0 Avoid an unhandled exception in the API thread.
When receiving a failover request with no data or
non-JSON data, emit a message to the client instead
of crashing.
2016-03-04 19:21:14 +01:00
Oleksii Kliukin 3f1c34f557 Add tests for the scheduled failover.
The actual amount of time to establish the master and the replication
after the scheduled failover seems sufficient (15 seconds with the
failover in 10 seconds), but occasionally leads to test failures.
This is unlikely the test issue and should be investigated inside
the patroni.
2016-03-02 19:39:12 +01:00
Oleksii Kliukin 58749b1dd6 Merge branch 'master' into feature/acceptance_tests 2016-03-02 16:17:21 +01:00
Oleksii Kliukin 069440be15 Improve the "replication work" sentence definition.
Add an ability to specify the origin and the destination for
the replication works clause. Use this ability in the API
promotion test to ensure the replication from the former
replica to the former master.
2016-03-02 15:43:44 +01:00
Oleksii Kliukin 24ebcc72f6 Add more tests for the restart and promotion. 2016-03-01 22:07:18 +01:00
Oleksii Kliukin ed15f7cd73 Improve tests start/stop, add etcd logging.
Toggle the etcd debug logging and write the log to the test dir.

Make sure etcd and patroni are terminated when the tests finish
by sending SIGKILL in case SIGTERM does not work.

Make sure before.all code does the proper cleanup when the exception
is thrown.
2016-03-01 22:03:38 +01:00
Oleksii Kliukin fa1a7687e5 Correct the step definition, randomize the table.
Make sure the step definition does not include "command" worlds.
Use the table name that includes current timestamp in the tests.
2016-03-01 22:00:30 +01:00
Oleksii Kliukin 0d44e3eb7c Add simple API tests for 2 nodes, to be extended. 2016-02-26 18:00:11 +01:00
Oleksii Kliukin 4e9ebf48a8 Add API tests for a stand-alone node. Bugfixes.
Add tests for patroni API.
Fix test failures when an already running etcd is used.
2016-02-26 17:37:37 +01:00
Oleksii Kliukin 45cb3f9696 Merge branch 'master' of https://github.com/zalando/patroni 2016-02-26 10:54:18 +01:00
Oleksii Kliukin e564fa7f08 Update DCS status right after acquiring the lock.
This commit only handles the initial bootstrap case, uncovered
by the upcoming lettuce tests
2016-02-26 10:53:00 +01:00
Oleksii Kliukin 83b7c34b00 Do not try to close an already closed file. 2016-02-25 15:35:15 +01:00
Oleksii Kliukin a84a3fc5e1 Changeset missing in the previous commit. 2016-02-25 15:16:35 +01:00
Oleksii Kliukin 67f55b4606 Stylistic issues: clearly mark unused variables. 2016-02-25 15:11:48 +01:00
Oleksii Kliukin 4a8edf44e6 Convert normal methods to static methods when possible. 2016-02-25 14:55:29 +01:00
Oleksii Kliukin 481a80a3ce Fix another couple of warnings from the QuantifiedCode and Co. 2016-02-25 14:39:22 +01:00
Oleksii Kliukin 4986db5c6a Code refactoring, no functional changes.
Move etcd code into a separate class.
Reduce the number of global interdependencies.
Clearly define private members of PatroniController and EtcdController.

It would not make the QuantifiedCode entirely happy, since lettuce
passes the step argument to the step definition, that is not used
in the client code, but internally (via the @steps decorator on
the steps class), but that's the issue of the tool used.
2016-02-25 12:52:45 +01:00
Oleksii Kliukin 53b5dfe39e Remove an unused function. 2016-02-24 19:24:46 +01:00
Oleksii Kliukin c9b8c2d3a9 Bugfixes, add a function to kill patroni daemon, make the feature description more concise. 2016-02-24 19:22:42 +01:00
Oleksii Kliukin 6f03953268 Merge basic failover and basic replication scenarios in one feature. 2016-02-24 17:12:45 +01:00
Oleksii Kliukin 6ec3523748 Collect test output, add basic failover test. 2016-02-24 16:30:52 +01:00
Oleksii Kliukin 287c0b3125 Fix the call to the function that was forgotten to be renamed. 2016-02-22 14:31:29 +01:00
Oleksii Kliukin 26e1586288 Make the patronictl test provide an input for the schedule, even if it's empty. 2016-02-22 12:20:20 +01:00
Oleksii Kliukin f781d0b9fe Address the code review by Alex Shulgin. 2016-02-16 16:50:50 +01:00
Oleksii Kliukin 435eeeb85d Add postgres2.yml as well. 2016-02-10 10:30:05 +01:00
Oleksii Kliukin a513893a19 Really fix the sample configuration files. 2016-02-10 10:29:21 +01:00
Oleksii Kliukin 7ab366a735 Fix psycopg2 username/user confusion.
Make sure username is translated into the user when calling
psycopg2.connect. Also, fix the sample configuration files to use
username everywhere.
2016-02-10 10:26:22 +01:00
Oleksii Kliukin 38bd037d99 Add the 1st lettuce test for the basic replication.
Basically check that the table inserted on the primary
will get its way to the secondary.
2016-02-05 13:30:42 +01:00
Oleksii Kliukin 09ecd1cbec Fix another issue with replication slots.
Do not try to create replication slots on the replica for the
member that wants to replicate from it if the member's currently
holds the master role.

Remove a debug message.
2016-02-04 19:27:26 +01:00
Oleksii Kliukin 03b56ae5b9 Code refactoring per review by Alex Shulgin.
In particular, rename most of the functions that have leader
in the name if they can be called in the context where the
leader is None.
2016-02-04 19:14:22 +01:00
Oleksii Kliukin 5284a2144d Add maintainers file. 2016-02-04 18:55:02 +01:00
Oleksii Kliukin 1a87bbd830 Fix handling of replication slots on the master.
Master shouldn't keep a replication slot for the members that
replicate from other members instead of the master (replicatefrom).
Otherwise, the master will keep collecting WAL segments that won't
be requested ever. Of course, if the destination of replicatefrom
is not part of the cluster, master should create the slot.
2016-02-04 15:31:22 +01:00
Oleksii Kliukin 458f12f8a2 Rename the badly named parameter. 2016-02-04 12:24:31 +01:00
Oleksii Kliukin 2d457ae26a Fix a problem with mutable default arguments.
Also bump up the version of python-etcd in requirements to the
latest one that that does not have https://github.com/jplana/python-etcd/issues/152
2016-02-01 11:37:59 +01:00
Oleksii Kliukin abaef49670 Disable auth in order to use patronictl with the default configuration, remove obsolete replication_methods like. 2016-01-29 09:05:52 +01:00
Oleksii Kliukin d1e54174c7 Make the code slightly more readable. 2016-01-27 13:13:52 +01:00
Oleksii Kliukin 72d30974ad Another attempt at making the Quantifiedcode happy. 2016-01-26 16:22:28 +01:00
Oleksii Kliukin c9de062ef5 declare the test as a static method to make the code analyzing tool happy. 2016-01-26 16:07:17 +01:00
Oleksii Kliukin aa350b7139 Increase the tests coverage. 2016-01-26 15:57:23 +01:00
Oleksii Kliukin 34437550d4 Fix a new flake8 warning (line break before the binary operator) 2016-01-26 15:40:53 +01:00
Oleksii Kliukin 15bec1e28c Support new replicas without the master.
The replication method should have no_master flag set and
support getting the base backup from some external storage
(i.e. S3). At the moment we only support initialization of
replicas in the already existing cluster when no master is
present, since there is no 'one fits all' way to decide whether
to run initidb or wait for the replica data storage to become
available when dealing with the new cluster.
2016-01-26 15:24:32 +01:00
Oleksii Kliukin c650dc092e Follow the node in the replicatefrom if present.
Rename the follow_the_leader to just follow, since the node to
be followed is not necessary a leader anymore. Extend the code
that manages replication slots to the non-master nodes if they
are mentioned in at least one replicatefrom tag.
Add the 3rd configuration in order to be able to run cascading
replicas.
2015-12-30 18:33:23 +01:00
Oleksii Kliukin bf52fa6f57 follow_the_leader unconditionally during recovery.
Otherwise, we may 'forget' to start the crashed node.
This fixes the regression from the former behavior introduced
in the previous commit.
2015-12-30 16:05:06 +01:00
Oleksii Kliukin 8ac731788d Merge branch 'master' into feature/cascading_replicas 2015-12-30 10:46:03 +01:00
Oleksii Kliukin 39cbd5f1d6 Unify all follow the leader calls from eventloop.
Call normal follow the leader method from HA even during recovery.
This provides a single place that changes recovery.conf, making
it easier to plug in a cascading replica in the future.

Remove an obsolete demote function from PostreSQL module, modified
the tests.
2015-12-11 18:54:38 +01:00
Oleksii Kliukin a4af9f2a4c Add replicafrom tag. 2015-12-11 18:54:03 +01:00
Oleksii Kliukin b2cd6d9113 Fix for the crash due to a missing initidb section in the configuration file 2015-12-11 10:36:39 +01:00
Oleksii Kliukin 39beb9cbb3 Bump up minor version. 2015-12-10 09:51:28 +01:00
Oleksii Kliukin d0c84c87ba Fix the formatting, add the missing changes to configuration files. 2015-12-09 13:56:37 +01:00
Oleksii Kliukin c5285bc293 Call a checkpoint on master before pg_rewind.
PostgreSQL does not run a checkpoint during promition.
Since pg_rewind relies on the last checkpoint to get the timeline,
there is a short race condition right after the promotion, when
it can get the timeline wrong and fail. We work around this by
calling the checkpoint manually.

Make sure our test configuration does both archive and recovery.
2015-12-09 13:17:36 +01:00
Oleksii Kliukin 2e9ac89591 Install patroni scripts alongside patroni, fix Oleksii's name. 2015-11-25 16:09:47 +01:00
Oleksii Kliukin 78f0b7e681 Add main() function inside the scripts/
We need this in order to install those scripts via pip.
2015-11-25 16:07:13 +01:00
Oleksii Kliukin daf9075b2f Merge branch 'master' of https://github.com/zalando/patroni 2015-11-25 15:05:11 +01:00
Oleksii Kliukin d4ab4d1aef Output the method used to initialize the replica. 2015-11-25 14:48:59 +01:00
Oleksii Kliukin 14b8dfa3e8 Make create_replica_method a YAML array.
Make sure the absense of this key or empty value in it is handled
correctly. Update tests and sample configuration files.
2015-11-25 10:29:17 +01:00
Oleksii Kliukin be9e525739 Remove an unused line. 2015-11-24 17:23:38 +01:00
Oleksii Kliukin d8a8fe9a80 Convert build_connstring into a one-liner, per code review by Alex. 2015-11-24 16:40:18 +01:00
Oleksii Kliukin 4b1ff5a4bb Code refactoring, per code review by Alex. 2015-11-24 16:37:40 +01:00
Oleksii Kliukin 6d296b1b34 Make sure params passed to the replica creation method are always defined. Per code review by Alex. 2015-11-24 16:26:08 +01:00
Oleksii Kliukin 1838b633e5 Merge branch 'pgexperts-restore/movebasebackup' of https://github.com/zalando/patroni into pgexperts-restore/movebasebackup 2015-11-24 16:16:05 +01:00
Oleksii Kliukin aee7d32af6 Small code improvement, per comment by Alex. 2015-11-24 16:14:39 +01:00
Oleksii Kliukin fcbb820949 Remove some cruft from the tests. 2015-11-24 15:43:56 +01:00
Oleksii Kliukin f3d9edb57f also add -p 1 to the restore commands provided with sample yaml files. 2015-11-24 15:32:44 +01:00
Oleksii Kliukin daf2a2686b Merge branch 'pgexperts-restore/movebasebackup' of https://github.com/zalando/patroni into pgexperts-restore/movebasebackup 2015-11-24 15:22:44 +01:00
Oleksii Kliukin 35efd36c5c Improve unittests and make minor bugfixes.
In particular, remove restore.py in favor of
wale_restore.py, fix minor bugs in the latter
and add unit tests.
2015-11-24 15:21:47 +01:00
Oleksii Kliukin e625c33bef Merge branch 'master' into pgexperts-restore/movebasebackup 2015-11-23 15:42:26 +01:00
Oleksii Kliukin 58d1a8a869 Add missing whitespaces 2015-11-23 15:38:50 +01:00
Oleksii Kliukin 5370b46c65 Make sure WAL-E restore script returns 1 if criterias to use WAL-E were not met. 2015-11-23 15:27:15 +01:00
Oleksii Kliukin e3961ee70b Simplify the condition when handling postgresql status request failures. 2015-11-23 12:59:01 +01:00
Oleksii Kliukin e6b6086e31 Avoid excessive log output in the API thread.
Set log level for BaseHTTPRequestHandler request logging to debug.
Avoid complains about PostgreSQL being unreachable if we know it
is not running.
2015-11-23 12:44:38 +01:00
Oleksii Kliukin 4814e82055 Fix a typo and an error in calling subprocess.call. 2015-11-20 17:55:51 +01:00
Oleksii Kliukin d59ccd1d8e Fix a couple of logical issues.
- command is deleted from method_config without checking whether
   it was there in the first place.
 - write_recovery_conf is called before the recovery file is restored
   from the backup location.
2015-11-20 14:22:25 +01:00
Oleksii Kliukin 7bc5ed7e4d Small fixes and an executable bit for wale script. 2015-11-18 18:03:38 +01:00
Oleksii Kliukin fef7d45208 Handle unexpected exceptions in etcd.
Previously, patroni would die after receiving an exception
other than RetryFailedError, etcd.EtcdException from etcd.
We have observed an AttributeError raised by etcd on some
occasions. With this change, we demote ourselves, but not
terminate on such exceptions.
2015-11-17 16:08:58 +01:00
Oleksii Kliukin 87a5646ad0 Merge branch 'restore/movebasebackup' of https://github.com/pgexperts/patroni into pgexperts-restore/movebasebackup 2015-11-16 12:04:32 +01:00