Oleksii Kliukin
af10bb8ab8
make sure replica-creation scripts are also available to patroni docker image.
2015-08-25 18:22:47 +02:00
Oleksii Kliukin
6b60be09a1
include restore command in the entyrpoint
2015-08-25 16:19:22 +02:00
Oleksii Kliukin
824819bbff
Make script compatible with boot2docker on OS X by exporting the correct LC_ variable and running docker with -P, exposing the ports to the underlying OS.
2015-08-25 16:18:59 +02:00
Oleksii Kliukin
29434e24ea
Allow relative paths to external scripts.
2015-08-24 16:53:57 +02:00
Oleksii Kliukin
164b5760a4
remove line too long warnings where possible.
2015-08-07 16:35:00 +02:00
Oleksii Kliukin
5d1d59a42b
Add mock-based unit tests for the restore module.
...
- add unit tests for the restore module
- additional dependencies in requirement
- harden the code that calls restore callbacks
- remove WAL-E related code from postgresql.py
2015-08-07 16:05:17 +02:00
Oleksii Kliukin
74a1daad09
fix a typo in the named tuple definition.
2015-08-04 17:13:36 +02:00
Oleksii Kliukin
8bed553d30
Use new-style classes.
2015-08-04 16:52:03 +02:00
Oleksii Kliukin
e69f015369
switch to using WAL-E by default.
2015-08-04 16:22:46 +02:00
Oleksii Kliukin
67da1b3a78
Make parse_connstring staticmethod less 'selfish'
2015-08-04 15:26:12 +02:00
Oleksii Kliukin
f17b651107
Adoprt WAL-E related code for a stand-alone script.
...
- make sure all parameters are taken from the env variables.
- make sure WAL-E code is not involved if the image is not configured for it
- pick up pg_basebackup as an alternative if WAL-E fails.
The WAL-E support will be switched on in subsequent commits.
2015-08-04 14:10:11 +02:00
Oleksii Kliukin
fd884a53a9
Multiple small fixes:
...
- Do delete trigger file in the patroni itself.
- Fix the typo in the datadir member.
- Add #! at the top of the python script.
2015-08-03 15:51:40 +02:00
Oleksii Kliukin
2089a123c2
fix line too long warning.
2015-08-03 11:48:02 +02:00
Oleksii Kliukin
7f2dcc0a95
Move replica creation code into a separte file. So far, only the class that makes replicas with pg_basebackup is called.
2015-08-03 11:44:11 +02:00
Oleksii Kliukin
a0fdd6398f
Cosmetic changes: avoid magic strings in action names, name the parameter passed to the callback 'scope' for consistency.
2015-07-30 10:17:17 +02:00
Oleksii Kliukin
71a1200f64
Fix a mistake in checking for the number of parameters.
2015-07-29 12:09:17 +02:00
Oleksii Kliukin
5171964758
Merge branch 'master' into feature/callbacks
2015-07-27 16:19:03 +02:00
Oleksii Kliukin
5c5bae69ea
make sure we can import from scripts.
2015-07-27 16:11:58 +02:00
Oleksii Kliukin
27bda5b4e4
document the new callbacks option.
2015-07-27 13:12:08 +02:00
Oleksii Kliukin
7d1bc32ad9
potentially run the doctests for the scripts.
2015-07-27 13:06:44 +02:00
Oleksii Kliukin
d85451efae
Increase test coverage for aws script.
2015-07-27 13:04:45 +02:00
Oleksii Kliukin
b92bfb34a5
Futher test for postgresql module (includes callbacks)
2015-07-27 13:04:01 +02:00
Oleksii Kliukin
56983d867d
Run coverage test for the data in scripts as well as helpers.
2015-07-27 13:03:12 +02:00
Oleksii Kliukin
115ba1d9ae
Make sure postgresql.stop also return True if pg_ctl stop returned 0.
2015-07-27 11:23:08 +02:00
Oleksii Kliukin
201f9bf4b2
Make sure role check during callbacks does not accidentially modify the cluster state (is_promoted flag or trigger file).
2015-07-27 11:08:19 +02:00
Oleksii Kliukin
859da0db0a
Make unit tets run again.
2015-07-27 10:10:29 +02:00
Oleksii Kliukin
dac3d7997f
Change a typo.
2015-07-24 10:47:26 +02:00
Oleksii Kliukin
35fe536e8b
Set +x bit on aws.py
2015-07-23 17:09:39 +02:00
Oleksii Kliukin
c9c678fb5b
Pass scope, the cluster name, instead of the name, which is the instance name, to the callback.
2015-07-23 16:16:22 +02:00
Oleksii Kliukin
f1d76611b6
Use the executable bit on AWS callback.
2015-07-17 17:26:52 +02:00
Oleksii Kliukin
e9934be9aa
Do not terminate on callback failure.
...
Show the error if a callback command fails and move on.
Set the executable bit for the aws callback.
2015-07-17 17:26:28 +02:00
Oleksii Kliukin
a11d94aff5
Pass text names of cluster roles to the script.
...
Seems better than passing a bool flag and
converting it from/to string.
2015-07-17 15:39:34 +02:00
Oleksii Kliukin
33b5e1b22e
Make sure is_leader is False does not trigger the leader re-check.
2015-07-17 15:22:21 +02:00
Oleksii Kliukin
11004f8c48
Be more robust on callbacks when cluster is down.
...
For 'on_stop' or 'on_restart' callbacks we cannot
call is_leader, because the cluster would be stopped.
Instead, call is_leader before running a callback.
In addition, make the call_nowait more robust by handling
the exceptions related to the DB cluster unavailability.
2015-07-17 11:19:05 +02:00
Oleksii Kliukin
d8aa1ff849
fix a typo.
2015-07-14 09:22:49 +02:00
Oleksii Kliukin
15f94f4224
Use actual role name and not boolean flag if it is a master to tag AWS objects (EBS volumes and EC2 instances).
2015-07-13 11:47:55 +02:00
Oleksii Kliukin
f734272f3f
Process the command paths relative to the patroni dir correctly, fix the error of not supplying a callback action to the actual command.
2015-07-13 11:45:25 +02:00
Oleksii Kliukin
6d0a9bbdc0
create a new directory for callback scripts and move aws volume tags there.
2015-07-13 10:25:42 +02:00
Oleksii Kliukin
c0cc590938
Remove usage of AWS.py from Patroni
...
Functionality provided by that module will be achieved via callbacks.
- fix a typo in aws.py
- fix some mixups of old code and new callbacks in postgresql.py
2015-07-10 12:58:37 +02:00
Oleksii Kliukin
78f0b16543
Enable aws.py to run as a stand-alone program.
2015-07-10 10:57:24 +02:00
Oleksii Kliukin
2c1627c2f3
get rid of yaml module, since AWS instance-identity natively sends JSON.
2015-07-10 10:33:07 +02:00
Oleksii Kliukin
aa5a72fb37
Add on_start, on_stop, on_role_change, on_restart and on_reload callbacks.
2015-07-09 15:45:10 +02:00
Oleksii Kliukin
1fc3582e9b
Merge branch 'feature/awstags' of https://github.com/zalando/governor into feature/awstags
2015-06-05 17:07:20 +02:00
Oleksii Kliukin
16a068f795
use instance-identity/document URL part to get instanceid and region at once.
2015-06-05 17:07:10 +02:00
Oleksii Kliukin
a6fcd66819
line up dependency alphabetically.
2015-06-05 10:07:24 +02:00
Oleksii Kliukin
8ab7717f13
increase test coverage for the changes in postgresql.py
2015-06-05 10:03:42 +02:00
Oleksii Kliukin
cdc7526216
Merge branch 'master' into feature/awstags
2015-06-05 09:50:17 +02:00
Oleksii Kliukin
20c785b63a
python3 compatibility: use isinstance instead of type()
2015-06-05 09:44:47 +02:00
Oleksii Kliukin
553b26f385
call on_change_callback only if it has been set.
2015-06-05 09:01:42 +02:00
Oleksii Kliukin
e2de4c9045
add ok flag to the MockResponse object in order to be compatible with the AWS code, which examines this flag in a callback.
2015-06-05 08:59:32 +02:00
Oleksii Kliukin
1ae19f758b
update requirements.txt with boto.
2015-06-05 08:48:57 +02:00
Oleksii Kliukin
3d123b41df
add unittests.
2015-06-04 17:19:33 +02:00
Oleksii Kliukin
ac46600816
more bugfixes.
2015-06-03 16:26:38 +02:00
Oleksii Kliukin
fb3bf799e9
Autodetect the host role during start from the existence of recovery.conf. Fix some typos.
2015-06-03 16:18:47 +02:00
Oleksii Kliukin
e06cd49deb
autodetect the host role during start from the existence of recovery.conf.
2015-06-03 16:13:03 +02:00
Oleksii Kliukin
1d3a946ffb
Fix wrong number of arguments for the EBS instance.
2015-06-03 15:52:35 +02:00
Oleksii Kliukin
c68beda75c
make sure on role change is called during the initial start of the server.
2015-06-03 15:49:38 +02:00
Oleksii Kliukin
0f518f87e7
fix a typo.
2015-06-03 14:45:02 +02:00
Oleksii Kliukin
eb3a120db1
add code to set tags on AWS objects (instances and EBS storage), as well as an ability for the postgres state_handler to call a callback when the state is changed, and use the new AWS code in a callback.
2015-06-03 12:56:00 +02:00
Oleksii Kliukin
7217d0b0c1
Fix typos when passing connection parameters to psycopg2.
2015-05-26 10:35:42 +02:00
Oleksii Kliukin
becce1dcf0
Merge branch 'master' of https://github.com/zalando/governor into s3_backups
2015-05-20 17:09:39 +02:00
Oleksii Kliukin
7dd1e295ca
re-add the encoding parameter to initdb.
2015-05-20 16:31:26 +02:00
Oleksii Kliukin
086ef4e0b1
Merge branch 's3_backups' of https://github.com/zalando/governor into s3_backups
2015-05-20 16:06:51 +02:00
Oleksii Kliukin
1c1a15908c
use governor yaml parameters and not environment variables to configure backups with WAL-E.
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
8a36f17d21
retry with pg_basebackup if one cannot get data from WAL-E.
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
3898610ea3
Put back the S3/pg_basebackup condition after testing.
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
4af752d668
revert the S3/pg_basebackup choice to unconditionally prefer S3 for testing purposes.
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
2efa97334b
returned the choice between S3 and pg_basebackup based on diff_in_bytes
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
e02eec91bf
save/restore both postgresql.conf and pg_hba.conf for WAL-e backup.
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
42dfaaab3f
write pg_hba.conf for the replica initialized from WAL-E. Temporarily use WAL-e always as a mean to create replica for testing purposes.
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
8a6a7b4cea
fix a typo.
2015-05-20 11:47:20 +02:00
Oleksii Kliukin
75b30d8014
save postgresql.conf not only on initdb, but on any start of the server.
2015-05-20 11:47:19 +02:00
Oleksii Kliukin
7a2be131bd
save/restore postgresql.conf for WAL-e backups, since WAL-E excludes postgresql.conf from the backup/restore.
2015-05-20 11:47:19 +02:00
Oleksii Kliukin
d4b366a7e2
some arithmetics and type conversion fixes.
2015-05-20 11:46:27 +02:00
Oleksii Kliukin
594efe3b64
fix a typo.
2015-05-20 11:46:26 +02:00
Oleksii Kliukin
19a04a81da
split arguments for check_output when checking for the latest backup.
2015-05-20 11:46:26 +02:00
Oleksii Kliukin
9e82c3ebd7
add functionality to fetch base backup from wal-e for the new replica creation and code to decide whether to use wal-e or pg_basebackup.
2015-05-20 11:46:26 +02:00
Oleksii Kliukin
5a579b0c92
use governor yaml parameters and not environment variables to configure backups with WAL-E.
2015-05-20 10:20:52 +02:00
Oleksii Kliukin
6a08213948
retry with pg_basebackup if one cannot get data from WAL-E.
2015-05-19 17:16:07 +02:00
Oleksii Kliukin
2191b0227d
Put back the S3/pg_basebackup condition after testing.
2015-05-19 14:56:36 +02:00
Oleksii Kliukin
ab17836aee
revert the S3/pg_basebackup choice to unconditionally prefer S3 for testing purposes.
2015-05-19 14:45:35 +02:00
Oleksii Kliukin
9e25b3a78c
returned the choice between S3 and pg_basebackup based on diff_in_bytes
2015-05-19 14:41:20 +02:00
Oleksii Kliukin
d8d9da12ff
save/restore both postgresql.conf and pg_hba.conf for WAL-e backup.
2015-05-19 14:33:13 +02:00
Oleksii Kliukin
a8a5c104ce
write pg_hba.conf for the replica initialized from WAL-E. Temporarily use WAL-e always as a mean to create replica for testing purposes.
2015-05-19 14:24:01 +02:00
Oleksii Kliukin
36282a10b2
fix a typo.
2015-05-19 14:04:51 +02:00
Oleksii Kliukin
380f0a27ac
save postgresql.conf not only on initdb, but on any start of the server.
2015-05-19 13:56:42 +02:00
Oleksii Kliukin
ae631aae69
save/restore postgresql.conf for WAL-e backups, since WAL-E excludes postgresql.conf from the backup/restore.
2015-05-19 12:01:45 +02:00
Oleksii Kliukin
9fc412a673
some arithmetics and type conversion fixes.
2015-05-19 10:32:48 +02:00
Oleksii Kliukin
ea5b4e9725
fix a typo.
2015-05-19 10:07:12 +02:00
Oleksii Kliukin
20fa4b21ca
split arguments for check_output when checking for the latest backup.
2015-05-19 09:19:53 +02:00
Oleksii Kliukin
169288c46c
add functionality to fetch base backup from wal-e for the new replica creation and code to decide whether to use wal-e or pg_basebackup.
2015-05-18 18:05:04 +02:00
Oleksii Kliukin
609a4b2fc6
loop until we reap all terminated children.
2015-05-13 12:22:17 +02:00
Oleksii Kliukin
8ad751b661
add a simplest SIGCHLD handler in order to avoid zombies in the docker container governed by the script
2015-05-13 10:05:12 +02:00
Oleksii Kliukin
35b111083c
Change the governor health check default port to 8008 in order to avoid a conflict with etcd proxy.
2015-05-11 17:55:00 +02:00
Oleksii Kliukin
39667f6e92
allow connections for all hosts and ports, not just postgres.
2015-04-30 12:11:46 +02:00
Oleksii Kliukin
221ba39c0f
Remove WITH invokations from CREATE ROLE.
2015-04-30 12:04:57 +02:00
Oleksii Kliukin
e8345e5e90
fix a typo.
2015-04-30 11:56:13 +02:00
Oleksii Kliukin
10dbf990f1
Allow md5 connections from outside and create connection roles.
...
Create a superuser role with a given name and password (or change
the postgres role if the name is not given). Also, create an admin
role with the name and the password provided. The admin role has
CREATEDB and CREATEROLE permisssions, effectively making it the
most powerful role after the superuser.
2015-04-30 10:58:07 +02:00
Oleksii Kliukin
8184efbf45
Add an option to use AWS instance address in a PostgreSQL connection string.
...
When PostgreSQL is running inside the docker container, it should provide
the address of the host it's running on and not the address from inside
of the container to the outside world.
2015-04-29 12:54:29 +02:00
Oleksii Kliukin
c3ea0ebccd
use samehost instead of the host's ip address.
2015-04-24 18:06:20 +02:00