Implement uWSGI for octavia-api

As part of the Pike goals we are moving api services to run as WSGI
apps. octavia-api service is set up as a wsgi app, and this patch
moves it over to uWSGI.

Since this is just a drop in replacement for the existing eventlet
service, operators an deployers should notice no difference.

Additionally, fix bug whereby git_install_branch was set to
"stable/ocata" for testing.

Change-Id: I0c473977e015015bd252a486c7191a95781b38a4
Implements: blueprint goal-deploy-api-in-wsgi
This commit is contained in:
Andy McCrae 2017-08-03 14:52:58 +01:00
parent 22b714518a
commit b1fe866f42
7 changed files with 89 additions and 5 deletions

View File

@ -166,6 +166,7 @@ octavia_pip_packages:
- python-swiftclient - python-swiftclient
- python-troveclient - python-troveclient
- octavia - octavia
- uwsgi
octavia_api_init_overrides: {} octavia_api_init_overrides: {}
octavia_worker_init_overrides: {} octavia_worker_init_overrides: {}
@ -178,6 +179,13 @@ octavia_services:
group: octavia_api group: octavia_api
service_name: octavia-api service_name: octavia-api
init_config_overrides: "{{ octavia_api_init_overrides }}" init_config_overrides: "{{ octavia_api_init_overrides }}"
wsgi_overrides: "{{ octavia_api_uwsgi_ini_overrides }}"
wsgi_app: True
log_string: "--logto "
wsgi_name: octavia-wsgi
uwsgi_port: "{{ octavia_service_port }}"
uwsgi_bind_address: "{{ octavia_uwsgi_bind_address }}"
program_override: "{{ octavia_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini"
octavia-worker: octavia-worker:
group: octavia_worker group: octavia_worker
service_name: octavia-worker service_name: octavia-worker
@ -369,6 +377,14 @@ octavia_iptables_rules:
reject_with: icmp6-port-unreachable reject_with: icmp6-port-unreachable
ip_version: ipv6 ip_version: ipv6
# uWSGI Settings
octavia_wsgi_processes_max: 16
octavia_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, octavia_wsgi_processes_max] | min }}"
octavia_wsgi_threads: 1
octavia_wsgi_buffer_size: 65535
octavia_uwsgi_bind_address: "0.0.0.0"
octavia_api_uwsgi_ini_overrides: {}
# Set up the drivers # Set up the drivers
octavia_amphora_driver: amphora_haproxy_rest_driver octavia_amphora_driver: amphora_haproxy_rest_driver
octavia_compute_driver: compute_nova_driver octavia_compute_driver: compute_nova_driver

View File

@ -0,0 +1,15 @@
---
features:
- The ``octavia-api`` service has moved to run as a
uWSGI application. You can set the max number of
WSGI processes, the number of processes, threads,
and buffer size utilizing the
``octavia_wsgi_processes_max``,
``octavia_wsgi_processes``, ``octavia_wsgi_threads``,
and ``octavia_wsgi_buffer_size``.
Additionally, you can override any settings in the
uWSGI ini configuration file using the
``octavia_api_uwsgi_ini_overrides`` setting.
The uWSGI application will listen on the address
specified by ``octavia_uwsgi_bind_address`` which
defaults to ``0.0.0.0``.

View File

@ -40,6 +40,10 @@
tags: tags:
- octavia-install - octavia-install
- include: octavia_uwsgi.yml
tags:
- octavia-config
- include: octavia_init_common.yml - include: octavia_init_common.yml
tags: tags:
- octavia-install - octavia-install

32
tasks/octavia_uwsgi.yml Normal file
View File

@ -0,0 +1,32 @@
---
# Copyright 2017, 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.
- name: Ensure uWSGI directory exists
file:
path: "/etc/uwsgi/"
state: directory
mode: "0711"
- name: Apply uWSGI configuration
config_template:
src: "octavia-uwsgi.ini.j2"
dest: "/etc/uwsgi/{{ item.value.service_name }}.ini"
mode: "0744"
config_overrides: "{{ item.value.wsgi_overrides }}"
config_type: ini
with_dict: "{{ octavia_services }}"
when: item.value.wsgi_app | default(False)
notify:
- Restart octavia services

View File

@ -10,10 +10,10 @@ Type=simple
User={{ octavia_system_user_name }} User={{ octavia_system_user_name }}
Group={{ octavia_system_group_name }} Group={{ octavia_system_group_name }}
{% if program_override is defined %} {% if item.value.program_override is defined %}
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/octavia/{{ item.value.service_name }}.log ExecStart={{ item.value.program_override }} {{ item.value.program_config_options|default('') }} {{ item.value.log_string | default('--log-file=') }}/var/log/octavia/{{ item.value.service_name }}.log
{% else %} {% else %}
ExecStart={{ octavia_bin }}/{{ item.value.service_name }} {{ program_config_options|default('') }} --log-file=/var/log/octavia/{{ item.value.service_name }}.log ExecStart={{ octavia_bin }}/{{ item.value.service_name }} {{ item.value.program_config_options|default('') }} --log-file=/var/log/octavia/{{ item.value.service_name }}.log
{% endif %} {% endif %}
# Give a reasonable amount of time for the server to start up/shut down # Give a reasonable amount of time for the server to start up/shut down

View File

@ -0,0 +1,19 @@
[uwsgi]
uid = {{ octavia_system_user_name }}
gid = {{ octavia_system_group_name }}
virtualenv = /openstack/venvs/octavia-{{ octavia_venv_tag }}
wsgi-file = {{ octavia_bin }}/{{ item.value.wsgi_name }}
http-socket = {{ item.value.uwsgi_bind_address }}:{{ item.value.uwsgi_port }}
master = true
enable-threads = true
processes = {{ octavia_wsgi_processes }}
threads = {{ octavia_wsgi_threads }}
exit-on-reload = true
die-on-term = true
lazy-apps = true
add-header = Connection: close
buffer-size = {{ octavia_wsgi_buffer_size }}
thunder-lock = true
logfile-chmod = 644

View File

@ -86,8 +86,6 @@ octavia_package_state: latest
octavia_neutron_management_network_name: lbaas-mgmt octavia_neutron_management_network_name: lbaas-mgmt
octavia_management_net_subnet_cidr: 10.1.7.0/24 octavia_management_net_subnet_cidr: 10.1.7.0/24
octavia_git_install_branch: stable/ocata
octavia_ssh_enabled: True octavia_ssh_enabled: True
octavia_amphora_driver: "{% if test_octavia_amphora | bool %}amphora_haproxy_rest_driver{% else %}amphora_noop_driver{% endif %}" octavia_amphora_driver: "{% if test_octavia_amphora | bool %}amphora_haproxy_rest_driver{% else %}amphora_noop_driver{% endif %}"