Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HAProxy to route Postgresql and ElasticSearch connections #808

Merged
merged 4 commits into from
Apr 20, 2016

Conversation

stevendanna
Copy link
Contributor

This provides two new configuration options:

use_chef_backend
chef_backend_members

When use_chef_backend is true, HAProxy will be enabled with a
configuration that will route requests to Postgresql and Elasticsearch
to the current Chef Backend leader.

This provides two new configuration options:

   use_chef_backend
   chef_backend_members

When use_chef_backend is true, HAProxy will be enabled with a
configuration that will route requests to Postgresql and Elasticsearch
to the current Chef Backend leader.
@stevendanna stevendanna changed the title WIP Use HAProxy as to route Postgresql and ElasticSearch connections WIP Use HAProxy to route Postgresql and ElasticSearch connections Apr 14, 2016
# When Chef Backend is configured, this is too early to verify
# postgresql accessibility since we need to configure HAProxy
# first
if ! PrivateChef['use_chef_backend']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this flag, we can at some point get rid of the hacky "derive whether we really care about bootstrap" logic that's used to allow a front-end to do bootstrapping.

- The BootstrapValidator checks can't run because they require
  postgresql to be up.

- HAProxy needs some time to mark the non-leader backends as down.  Thus
  we wait for that to happen or error out if it doesn't happen in a
  reasonable amount of time.
@stevendanna stevendanna changed the title WIP Use HAProxy to route Postgresql and ElasticSearch connections Use HAProxy to route Postgresql and ElasticSearch connections Apr 18, 2016
- Move code for parsing HAProxy status socket responses into a
  HAProxyStatus class.

- Move code for determining backend cluster members into a ChefBackend
  module.
mode tcp
option httpchk GET /leader HTTP/1.1\r\nHost:localhost:<%= @leaderl_healthcheck_port %>\r\n\r\n
<% @chef_backend_members.each do |name, ip| -%>
server <%= name %> <%= ip %>:<%= @remote_postgresql_port %> check port <%= @leaderl_healthcheck_port %> rise 1 fall 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can specify defaults here up above for all the servers. Like:

default-server inter 3s fall 3 rise 2
server name ip:port check port
server name ip:port check port
...

https://www.haproxy.com/doc/aloha/7.0/haproxy/healthchecks.html

Reading the docs a little more there's actually built in support for postgres as well:

backend be_pgsql
 [...]
 option pgsql-check
 server srv1 10.0.0.1:5432 check
 server srv2 10.0.0.2:5432 check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using an HTTP check here because the /leader endpoint knows about the leader/follower state. (postgresql could be erroneously up as a leader while leaderl is in the process of taking it down. The /leader endpoint will return the correct thing in that case while a postgresql-based check may not).

@stevendanna
Copy link
Contributor Author

@dmccown Updated the PR to use the default-server config directive.

name "haproxy"
default_version "1.6.4"

dependency "zlib"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all of the dependencies run time dependencies? Is it worth it to prune the non-runtime deps at this time? I'm OK if there's another task to clean this up later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these are runtime deps since we don't do static linking, so zlib, pcre, openssl all have to be in the package.

@dmccown
Copy link

dmccown commented Apr 20, 2016

Other than my comment on dependencies and the comment you cleaned up on your last PR nothing is really jumping out at me. So overall I'm 👍

@stevendanna stevendanna merged commit 4a3a6e6 into master Apr 20, 2016
@stevendanna stevendanna deleted the ssd/add-ha-proxy branch April 22, 2016 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants