Commit Graph
105 Commits
Author SHA1 Message Date
Alexander Kukushkin 494d675f38 Merge pull request #7 from zalando/features/refactoring
Merge changes from compose/governer
2015-05-15 13:00:15 +02:00
Alexander Kukushkin 2fd81a5135 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring 2015-05-15 11:39:25 +02:00
Alexander Kukushkin 274bc14bfb Do not check maximum_lag_on_failover if it is not defined in config file 2015-05-15 11:38:50 +02:00
Alexander Kukushkin 8e5beb5883 Small optimization 2015-05-15 11:25:26 +02:00
Alexander Kukushkin 9487aec842 Bugfix: get_client_path might get into infinite loop when response code is not 200 2015-05-15 11:23:02 +02:00
Alexander Kukushkin 4e8a0873a7 Handle sigchld, so we can run governor and postgres inside docker safely 2015-05-13 18:05:42 +02:00
Alexander Kukushkin e6e19359df Bugfix, write state_handler.name into leader key 2015-05-13 18:04:27 +02:00
Alexander Kukushkin 0c040b8ce2 Merge branch 'master' of github.com:compose/governor
Conflicts:
	governor.py
	helpers/etcd.py
	helpers/ha.py
	helpers/postgresql.py
2015-05-13 18:01:01 +02:00
Feike Steenbergen d33555242d Merge pull request #6 from zalando/features/refactoring
Remove member and leader (is I was the master) keys from etcd on stop of governor
2015-05-13 17:17:51 +02:00
Alexander Kukushkin b4f0909afa Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring 2015-05-13 17:12:32 +02:00
Alexander Kukushkin 40a4192504 Remove member and leader (is I was the master) keys from etcd on stop of governor 2015-05-13 17:12:17 +02:00
Alexander Kukushkin 2541fcd3f2 Merge pull request #5 from zalando/features/refactoring
Features/refactoring
2015-05-13 15:37:43 +02:00
Alexander Kukushkin 3fa0476d8c Merge branch 'master' of github.com:zalando/governor into features/refactoring 2015-05-13 14:58:54 +02:00
Oleksii Kliukin fce99b6ec3 Merge pull request #4 from zalando/handle_sigchld
Handle sigchld
2015-05-13 14:58:31 +02:00
Alexander Kukushkin b1f43c1461 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring
Conflicts:
	helpers/postgresql.py
2015-05-13 14:57:57 +02:00
Alexander Kukushkin d25ad17c32 Add support of python3 2015-05-13 14:53:23 +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
Christopher Winslett f8c4993f16 add description of settings for yaml file 2015-05-12 18:53:57 -07:00
Christopher Winslett 2c69074652 move stale protection from is_healthy to is_healthiest to allow stale secondaries to rejoin cluster 2015-05-12 18:29:54 -07:00
Christopher Winslett 557bad37cd ensure a stale Postgres does not become leader 2015-05-12 18:11:12 -07:00
Christopher Winslett a1bc07db33 use TTLs with member listing to keep a current list of cluster members 2015-05-12 16:33:32 -07:00
Feike Steenbergen 127a03d23d Merge pull request #3 from zalando/feature/status_page
Refactoring of Governor, adding of a health check, setting default ports to sane values.
2015-05-12 15:50:28 +02:00
Feike Steenbergen 2b56379b85 Change default port for the health check to 8008. 2015-05-12 15:48:30 +02:00
Feike Steenbergen c4168bfeb5 Bugfix: Headers sent before http status for the pg_status page. 2015-05-12 14:56:02 +02:00
Feike Steenbergen 362b6b4fa2 Made healtcheck port configurable, fixed standalone status page. 2015-05-12 14:48:40 +02:00
Feike Steenbergen ed30684d85 Merge branch 'features/refactoring' of github.com:zalando/governor into feature/status_page
Conflicts:
	helpers/postgresql.py
2015-05-12 14:39:51 +02:00
Feike Steenbergen d25fdd41a6 Refactoring of the status page for the healthcheck.
Less functions, as the code is readable enough without them.
Always return some content to the client, instead of a response only.
2015-05-12 14:14:20 +02:00
Alexander Kukushkin 6043bf8c75 Fix imports 2015-05-12 14:07:10 +02:00
Alexander Kukushkin 788f65b406 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring
Conflicts:
	governor.py
2015-05-12 14:04:25 +02:00
Alexander Kukushkin 8b38dbd2b5 Put governor code into class and implement sigterm processing handler 2015-05-12 13:48:06 +02:00
Alexander Kukushkin 17112992d0 Merge branch 'master' of github.com:zalando/governor into features/refactoring
Conflicts:
	governor.py
2015-05-12 12:24:09 +02:00
Feike Steenbergen a56b346295 Hardened the health checks and implemented a real status page.
For the postgresql helper, hardened the code to get "the" cursor of the postgresql instance.
For the statuspage, a small status json is returned.
To find out what status a PostgreSQL cluster is in we use the cursor (instead of the provided query() function), as the query function does some retrying etc. For the healthcheck we want to simple provide an answer to a simple query, if we have to reconnect, we are not *that* healthy anyway.

Dropped catching exceptions in the do_GET block, as the HTTPServer will do that nicely for us anyway.
2015-05-12 11:58:47 +02:00
Alexander Kukushkin e21e896852 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring 2015-05-12 11:08:33 +02:00
Alexander Kukushkin 281b0b8455 Bugfix in has_lock: sometimes leader can be undefined 2015-05-12 11:07:52 +02:00
Alexander Kukushkin 9dcbc75fd2 Bugfix. It wasn't possible to start the old cluster if all its members were shutdown.
Basically this is rollback to the original decision tree with the small exception:
1 - If leader is defined and it's not me - then slave would be started immidiately
with the correct recovery conf.
2 - If leader is defined in and it's my host, then it will start instance in
readonly (but without primary_conninfo in recovery.conf)
3 - And the third case - if the leader is not defined - it also will start
instance in readonly, without primary_conninfo.
After performing 2 or 3 it will perform usual decision tree.
2015-05-12 10:19:45 +02:00
Alexander Kukushkin 41942ee722 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring 2015-05-12 09:09:49 +02:00
Alexander Kukushkin be7677a1b8 Bugfix, hostname and address are not keys of dict but properties of Member object 2015-05-12 09:08:45 +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
Alexander Kukushkin 1370923e84 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring 2015-05-11 16:58:26 +02:00
Alexander Kukushkin e2faf641d5 Start slave with the correct recovery.conf on governor start
Also governor is able to pick up already running master and slave
instances without restarting them.
In case is you have a lock and postgres is not running behaviour remains
the same: it will start master in read only mode and then promote if it
still has the lock.
2015-05-11 16:50:21 +02:00
Feike Steenbergen 82afc554d6 Merge pull request #2 from zalando/feature/status_page
Created statuspage, a health check for a PostgreSQL cluster served usi…
2015-05-11 16:25:28 +02:00
Alexander Kukushkin eb1721f65f Minimize amount of requests to etcd 2015-05-11 15:15:08 +02:00
Feike Steenbergen e7adb69503 Start the http request handler for load balancing as a thread in Governor.
When not running standalone, some better referencing to the Postgresql instance was needed.
2015-05-11 13:11:09 +02:00
Feike Steenbergen 91b71f8579 Created tatuspage, a health check for a PostgreSQL cluster served using http.
The StatusPage uses a BaseHTTPServer to server 3 simple http endpoints:

- pg_master, returns 200 if PostgreSQL is running as master
- pg_slave,  returns 200 if PostgreSQL is running as slave
- pg_status, returns some information about the cluster

It does this by relying on the PostgreSQL connection of the Governor.
2015-05-11 11:46:01 +02:00
Alexander Kukushkin 42d9c08c37 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring 2015-05-11 10:06:29 +02:00
Alexander Kukushkin 6d17d39776 Backport from compose/governor: compare xlog positions based on bytes since 0/000000 based on feedback 2015-05-11 10:06:18 +02:00
Alexander Kukushkin b3d6997289 Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring 2015-05-11 09:54:28 +02:00
Alexander Kukushkin 2e3eb333cb Shutdown fast 2015-05-11 09:48:59 +02:00
Alexander Kukushkin 0b288a7f3e Track list of already existing physical replication slots
Drop replication slot when it was removed from etcd.
Execute pg_create_physical_replication_slot only when something new appeared in etcd.
2015-05-11 09:48:15 +02:00