Add ability to specify IP for service

The problem that this change addresses is that the address_for method
will not work correctly if there are multiple IP address associated
with the specified interface.

The approach to solving this problem and moving towards the overall
goal of having one place where service networking information is
stored is to convert address_for calls into endpoints, and add a
address() method to the endpoints interface for IP address resolution.

The address() method has the following behavior: if the
bind_interface of an endpoint is set, then the IP is looked up on
the interface.  Otherwise, the IP specified in the host attribute is
returned.  This allows the caller to choose either method of
determining what IP a service will be bound to.

This initial change switches both the openstack-ops-database and
openstack-ops-messaging cookbooks over to use endpoints instead of
address_for.  The other cookbooks will be switched over time.

blueprint increase-ip-binding-flexibility

Change-Id: I2d1c40ec79a2533be150c5b4ea6e1f396c500e9d
This commit is contained in:
Chris Dearborn 2014-02-18 14:49:54 -05:00
parent 27bbd6107a
commit e76386f81c
4 changed files with 14 additions and 7 deletions

View File

@ -69,9 +69,18 @@ None
# Attributes #
* `openstack["db"]["bind_interface"]` - bind to interfaces IPv4 address
* `openstack["db"]["platform"]["mysql_python_packages"]` - platform-specific mysql python packages to install
The following attributes are defined in attributes/database.rb of the common cookbook, but are documented here due to their relevance:
* `openstack["endpoints"]["db"]["host"]` - The IP address to bind the database service to
* `openstack["endpoints"]["db"]["scheme"]` - Unused at this time
* `openstack["endpoints"]["db"]["port"]` - The port to bind the database service to
* `openstack["endpoints"]["db"]["path"]` - Unused at this time
* `openstack["endpoints"]["db"]["bind_interface"]` - The interface name to bind the database service to
If the value of the "bind_interface" attribute is non-nil, then the database service will be bound to the first IP address on that interface. If the value of the "bind_interface" attribute is nil, then the database service will be bound to the IP address specified in the host attribute.
Testing
=====

View File

@ -18,8 +18,6 @@
# limitations under the License.
#
default['openstack']['db']['bind_interface'] = 'lo'
# Platform defaults
case platform
when 'fedora', 'redhat', 'centos' # :pragma-foodcritic: ~FC024 - won't fix this

View File

@ -24,9 +24,9 @@ class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
listen_address = address_for node['openstack']['db']['bind_interface']
db_endpoint = endpoint 'db'
node.override['mysql']['bind_address'] = listen_address
node.override['mysql']['bind_address'] = db_endpoint.host
node.override['mysql']['tunable']['innodb_thread_concurrency'] = '0'
node.override['mysql']['tunable']['innodb_commit_concurrency'] = '0'
node.override['mysql']['tunable']['innodb_read_io_threads'] = '4'

View File

@ -25,9 +25,9 @@ class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
listen_address = address_for node['openstack']['db']['bind_interface']
db_endpoint = endpoint 'db'
node.override['postgresql']['config']['listen_addresses'] = listen_address
node.override['postgresql']['config']['listen_addresses'] = db_endpoint.host
include_recipe 'openstack-ops-database::postgresql-client'
include_recipe 'postgresql::server'