Added openstack_kernel options for gc_thresh

This commit adds to the openstack_kernel_options to set the
"net.ipv4/6.neigh.default.gc_thresh*" values according to how much ram
is available on the box.

How this is being defined:
The change brings with it a filter to find the closest power of 2 from the
amount of ram discovered on the target host. If facts are disabled when the
role is called a default value of 1024 will be used. The `set_gc_val`, when
computed, has a max value of 8192. For both ipv4/6 thresh1 is half the
`set_gc_val` thresh2 is computed value, and finally both
thresh3/router.gc_thresh are double the `set_gc_val`.

The changes here should provide for a more scalable neutron networking
environment by default while also ensuring that the values computed are sane.
Additionallyi, should the user want to define their own values they can do so by
simply overriding the `set_gc_val`.

Change-Id: Ic5fd7ebdac009fa1472aeb0b0666f9b2611a31d7
Closes-Bug: #1427893
This commit is contained in:
kevin 2015-06-29 09:53:56 -05:00
parent 85905fbf8f
commit b95827f351
No known key found for this signature in database
GPG Key ID: 69FEFFC5E2D9273F
3 changed files with 61 additions and 0 deletions

View File

@ -1,6 +1,7 @@
[defaults]
# Additional plugins
lookup_plugins = plugins/lookups
filter_plugins = plugins/filters
gathering = smart
hostfile = inventory

View File

@ -0,0 +1,40 @@
# Copyright 2015, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# (c) 2015, Kevin Carter <kevin.carter@rackspace.com>
"""Filter usage:
Simple filters that may be useful from within the stack
"""
def bit_length_power_of_2(value):
"""Return the smallest power of 2 greater than a numeric value.
:param value: Number to find the smallest power of 2
:type value: ``int``
:returns: ``int``
"""
return 2**(int(value)-1).bit_length()
class FilterModule(object):
"""Ansible jinja2 filters."""
@staticmethod
def filters():
return {
'bit_length_power_of_2': bit_length_power_of_2
}

View File

@ -74,6 +74,14 @@ openstack_host_apt_packages:
- vlan
- wget
# The following garbage collection values are set to better support lots of neutron networks/routers.
# Used for setting the net.ipv4/6.neigh.default.gc_thresh* values. This assumes that facts were
# gathered to obtain the total amount of memory available on a given host. If no facts are gathered
# the default set will be 1024 unless its defined by the user.
gc_val: "{{ ansible_memtotal_mb | default(1024) | bit_length_power_of_2 }}"
# The ste value has a Max allowable value of 8192 unless set by the user.
set_gc_val: "{{ gc_val if (gc_val | int <= 8192) else 8192 }}"
# System control kernel tuning
openstack_kernel_options:
- { key: 'fs.inotify.max_user_watches', value: 36864 }
@ -84,3 +92,15 @@ openstack_kernel_options:
- { key: 'vm.dirty_background_ratio', value: 5 }
- { key: 'vm.dirty_ratio', value: 10 }
- { key: 'vm.swappiness', value: 5 }
- { key: 'net.ipv4.neigh.default.gc_thresh1', value: "{{ set_gc_val | int // 2 }}" }
- { key: 'net.ipv4.neigh.default.gc_thresh2', value: "{{ set_gc_val | int }}" }
- { key: 'net.ipv4.neigh.default.gc_thresh3', value: "{{ set_gc_val | int * 2 }}" }
- { key: 'net.ipv4.route.gc_thresh', value: "{{ set_gc_val | int * 2 }}" }
- { key: 'net.ipv4.neigh.default.gc_interval', value: 60 }
- { key: 'net.ipv4.neigh.default.gc_stale_time', value: 120 }
- { key: 'net.ipv6.neigh.default.gc_thresh1', value: "{{ set_gc_val | int // 2 }}" }
- { key: 'net.ipv6.neigh.default.gc_thresh2', value: "{{ set_gc_val | int }}" }
- { key: 'net.ipv6.neigh.default.gc_thresh3', value: "{{ set_gc_val | int * 2 }}" }
- { key: 'net.ipv6.route.gc_thresh', value: "{{ set_gc_val | int * 2 }}" }
- { key: 'net.ipv6.neigh.default.gc_interval', value: 60 }
- { key: 'net.ipv6.neigh.default.gc_stale_time', value: 120 }