From 0c17e691dc9abe143adc3c3a99b15e2563ac269c Mon Sep 17 00:00:00 2001 From: Darren Birkett Date: Thu, 10 Apr 2014 15:18:57 +0100 Subject: [PATCH] Allow binding locally to different IP than endpoint IP Sometimes you want the actual endpoint IP to be a load balanced IP, but the bind IP to be a local IP (different per node). This change allows that by using *-api-bind and *-registry-bind for the actual local bind addresses Implements blueprint increase-ip-binding-flexibility Change-Id: I4f6d854976ede6eaf280ba5e705d97f3bbc88fea --- README.md | 12 ++++++++++++ recipes/api.rb | 6 +++--- recipes/registry.rb | 6 +++--- spec/api_spec.rb | 2 +- spec/registry_spec.rb | 2 +- templates/default/glance-registry.conf.erb | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8eef3a5..51f23a8 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,18 @@ MQ attributes * `openstack['image']['mq']['qpid']['protocol']` - Protocol to use. Default tcp. * `openstack['image']['mq']['qpid']['tcp_nodelay']` - Disable the Nagle algorithm. default disabled. +The following attributes are defined in attributes/default.rb of the common cookbook, but are documented here due to their relevance: + +* `openstack['endpoints']['image-api-bind']['host']` - The IP address to bind the api service to +* `openstack['endpoints']['image-api-bind']['port']` - The port to bind the api service to +* `openstack['endpoints']['image-api-bind']['bind_interface']` - The interface name to bind the api service to + +* `openstack['endpoints']['image-registry-bind']['host']` - The IP address to bind the registry service to +* `openstack['endpoints']['image-registry-bind']['port']` - The port to bind the registry service to +* `openstack['endpoints']['image-registry-bind']['bind_interface']` - The interface name to bind the registry service to + +If the value of the 'bind_interface' attribute is non-nil, then the image service will be bound to the first IP address on that interface. If the value of the 'bind_interface' attribute is nil, then the image service will be bound to the IP address specified in the host attribute. + Testing ===== diff --git a/recipes/api.rb b/recipes/api.rb index cccb89a..4e832e1 100644 --- a/recipes/api.rb +++ b/recipes/api.rb @@ -132,7 +132,7 @@ elsif mq_service_type == 'qpid' end registry_endpoint = endpoint 'image-registry' -api_endpoint = endpoint 'image-api' +api_bind = endpoint 'image-api-bind' # Possible combinations of options here # - default_store=file @@ -172,8 +172,8 @@ template '/etc/glance/glance-api.conf' do group node['openstack']['image']['group'] mode 00644 variables( - api_bind_address: api_endpoint.host, - api_bind_port: api_endpoint.port, + api_bind_address: api_bind.host, + api_bind_port: api_bind.port, registry_ip_address: registry_endpoint.host, registry_port: registry_endpoint.port, sql_connection: sql_connection, diff --git a/recipes/registry.rb b/recipes/registry.rb index 68e569d..c1028bb 100644 --- a/recipes/registry.rb +++ b/recipes/registry.rb @@ -39,7 +39,7 @@ sql_connection = db_uri('image', db_user, db_pass) identity_endpoint = endpoint 'identity-api' identity_admin_endpoint = endpoint 'identity-admin' -registry_endpoint = endpoint 'image-registry' +registry_bind = endpoint 'image-registry-bind' service_pass = get_password 'service', 'openstack-image' auth_uri = auth_uri_transform identity_endpoint.to_s, node['openstack']['image']['registry']['auth']['version'] @@ -95,8 +95,8 @@ template '/etc/glance/glance-registry.conf' do group 'root' mode 00644 variables( - :registry_bind_address => registry_endpoint.host, - :registry_port => registry_endpoint.port, + :registry_bind_address => registry_bind.host, + :registry_bind_port => registry_bind.port, :sql_connection => sql_connection, :auth_uri => auth_uri, 'identity_admin_endpoint' => identity_admin_endpoint, diff --git a/spec/api_spec.rb b/spec/api_spec.rb index 9d0f696..7e3e269 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -119,7 +119,7 @@ describe 'openstack-image::api' do end it 'has bind host when bind_interface specified' do - node.set['openstack']['endpoints']['image-api']['bind_interface'] = 'lo' + node.set['openstack']['endpoints']['image-api-bind']['bind_interface'] = 'lo' match = 'bind_host = 127.0.1.1' expect(chef_run).to render_file(file.name).with_content(match) diff --git a/spec/registry_spec.rb b/spec/registry_spec.rb index c9ca3bc..250d65a 100644 --- a/spec/registry_spec.rb +++ b/spec/registry_spec.rb @@ -95,7 +95,7 @@ describe 'openstack-image::registry' do end it 'has bind host when bind_interface specified' do - node.set['openstack']['endpoints']['image-registry']['bind_interface'] = 'lo' + node.set['openstack']['endpoints']['image-registry-bind']['bind_interface'] = 'lo' match = 'bind_host = 127.0.1.1' expect(chef_run).to render_file(file.name).with_content(match) diff --git a/templates/default/glance-registry.conf.erb b/templates/default/glance-registry.conf.erb index 2dbda58..e45bf0d 100644 --- a/templates/default/glance-registry.conf.erb +++ b/templates/default/glance-registry.conf.erb @@ -11,7 +11,7 @@ debug = <%= node["openstack"]["image"]["debug"] %> bind_host = <%= @registry_bind_address %> # Port the bind the registry server to -bind_port = <%= @registry_port %> +bind_port = <%= @registry_bind_port %> # Backlog requests when creating socket backlog = 4096