Skip to content

Instantly share code, notes, and snippets.

@jprovaznik
Created July 11, 2014 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jprovaznik/81576ed823d627c1a6cc to your computer and use it in GitHub Desktop.
Save jprovaznik/81576ed823d627c1a6cc to your computer and use it in GitHub Desktop.
haproxy for rabbitmq - quick hack done on built image
[tripleo@ibm-x3550m3-15 tripleo-image-elements]$ git diff elements/rabbitmq-server/
diff --git a/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg b/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg
index eb9bcb8..98e07f1 100644
--- a/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg
+++ b/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg
@@ -40,6 +40,20 @@ listen {{name}}
{{/nodes}}
{{/services}}
+listen rabbitmq
+ {{#net_binds}}
+ bind {{ip}}:5672
+ {{/net_binds}}
+ timeout client 900m
+ default_backend rabbitmq-vms
+
+backend rabbitmq-vms
+ balance roundrobin
+ timeout server 900m
+ {{#nodes}}
+ server {{name}} {{ip}}:5672 check inter 1s
+ {{/nodes}}
+
{{/haproxy}}
{{^haproxy.stats.disabled}}
diff --git a/elements/rabbitmq-server/os-config-applier/etc/rabbitmq/rabbitmq.config b/elements/rabbitmq-server/os-config-applier/etc/rabbitmq/rabbitmq.config
index 13bbddf..2c26761 100644
--- a/elements/rabbitmq-server/os-config-applier/etc/rabbitmq/rabbitmq.config
+++ b/elements/rabbitmq-server/os-config-applier/etc/rabbitmq/rabbitmq.config
@@ -16,6 +16,7 @@
]
},
{rabbit, [
- {cluster_partition_handling, {{#rabbit.cluster_partition_handling}}{{rabbit.cluster_partition_handling}}{{/rabbit.cluster_partition_handling}}{{^rabbit.cluster_partition_handling}}pause
+ {cluster_partition_handling, {{#rabbit.cluster_partition_handling}}{{rabbit.cluster_partition_handling}}{{/rabbit.cluster_partition_handling}}{{^rabbit.cluster_partition_handling}}pause
+ {tcp_listeners, [{"{{local-ipv4}}", 5672}]}
]}
].
diff --git a/elements/rabbitmq-server/os-refresh-config/post-configure.d/40-rabbitmq b/elements/rabbitmq-server/os-refresh-config/post-configure.d/40-rabbitmq
index 7ecfe85..b83b4c5 100755
--- a/elements/rabbitmq-server/os-refresh-config/post-configure.d/40-rabbitmq
+++ b/elements/rabbitmq-server/os-refresh-config/post-configure.d/40-rabbitmq
@@ -46,7 +46,7 @@ function join_with() {
LOCAL=$(hostname -s)
# TODO - nodes are comma separated hostnames, there is probably no type for this
-NODES=$(os-apply-config --key rabbit.nodes --type raw --key-default '' | sed 's/,/\n/g')
+NODES=$(os-apply-config --key rabbit.cluster-nodes --type raw --key-default '' | sed 's/,/\n/g')
MASTER=$(echo "$NODES"|sort -n|head -1)
# Heat can return hostname with capital letters, cloud-init converts to lowercase. Make sure
[tripleo@ibm-x3550m3-15 tripleo-heat-templates]$ git diff
diff --git a/overcloud-source.yaml b/overcloud-source.yaml
index 61b08d3..d5485fe 100644
--- a/overcloud-source.yaml
+++ b/overcloud-source.yaml
@@ -519,6 +519,8 @@ Resources:
port: 8777
- name: swift_proxy_server
port: 8080
+ - name: rabbitmq
+ port: 5672
controllerPassthrough:
Type: OS::Heat::StructuredConfig
Properties:
@@ -646,7 +648,8 @@ Resources:
- 'novalocal'
- {Ref: CloudName}
rabbit:
- nodes:
+ nodes: {'Fn::Select': [ip_address, 'Fn::Select': [0, 'Fn::GetAtt': [ControlVirtualIP, fixed_ips]]]}
+ cluster-nodes:
Fn::Join:
- ','
- Merge::Map:
@jprovaznik
Copy link
Author

I used this hotfix for already built images to get quickly to haproxy setup, this obviously has to be transformed to a regular patch:

  1. rabbit.nodes metadata is used both for rabbitmq script and in OS config file templates - one of these places has to be renamed if we will use VIP - in this patch I renamed it in the script.
  2. custom options for haproxy.cfg - this is more tricky, the lines:
  • default_backend rabbitmq-vms

+backend rabbitmq-vms
can be probably omitted so that it will be:
+listen rabbitmq

  • {{#net_binds}}
  • bind {{ip}}:5672
  • {{/net_binds}}
  • timeout client 900m
  • balance roundrobin
  • timeout server 900m
  • {{#nodes}}
  • server {{name}} {{ip}}:5672 check inter 1s
  • {{/nodes}}

To be able to add extra options into haproxy template, new parameter (options) could be added:
diff --git a/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg b/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg
index eb9bcb8..e3aa291 100644
--- a/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg
+++ b/elements/haproxy/os-config-applier/etc/haproxy/haproxy.cfg
@@ -35,11 +35,28 @@ listen {{name}}
{{/balance}}
option tcpka
option tcplog

  • {{#options}}
  • {{,}}
  • {{/options}}
    {{#nodes}}
    server {{name}} {{ip}}:{{port}} check inter 2000 rise 2 fall 5
    {{/nodes}}
    {{/services}}

Then rabbitmq could be added into haproxy service in overcoud-source.yaml with something like this:

  •        - name: rabbitmq
    
  •          port: 5672
    
  •          balance: roundrobin
    
  •          options:
    
  •            - timeout client 900m
    
  •            - timeout server 900m
    

It's just a thought, any other way is welcome too :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment