diff --git a/defaults/main.yml b/defaults/main.yml index eced5919..18b26898 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -166,6 +166,7 @@ octavia_pip_packages: - python-swiftclient - python-troveclient - octavia + - uwsgi octavia_api_init_overrides: {} octavia_worker_init_overrides: {} @@ -178,6 +179,13 @@ octavia_services: group: octavia_api service_name: octavia-api 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: group: octavia_worker service_name: octavia-worker @@ -369,6 +377,14 @@ octavia_iptables_rules: reject_with: icmp6-port-unreachable 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 octavia_amphora_driver: amphora_haproxy_rest_driver octavia_compute_driver: compute_nova_driver diff --git a/releasenotes/notes/octavia_uwsgi-f5d10fec3c1950bf.yaml b/releasenotes/notes/octavia_uwsgi-f5d10fec3c1950bf.yaml new file mode 100644 index 00000000..8a9b1766 --- /dev/null +++ b/releasenotes/notes/octavia_uwsgi-f5d10fec3c1950bf.yaml @@ -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``. diff --git a/tasks/main.yml b/tasks/main.yml index 5c995215..3160dc37 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -40,6 +40,10 @@ tags: - octavia-install +- include: octavia_uwsgi.yml + tags: + - octavia-config + - include: octavia_init_common.yml tags: - octavia-install diff --git a/tasks/octavia_uwsgi.yml b/tasks/octavia_uwsgi.yml new file mode 100644 index 00000000..0e838f65 --- /dev/null +++ b/tasks/octavia_uwsgi.yml @@ -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 diff --git a/templates/octavia-systemd-init.j2 b/templates/octavia-systemd-init.j2 index fb9baeaf..54770f08 100644 --- a/templates/octavia-systemd-init.j2 +++ b/templates/octavia-systemd-init.j2 @@ -10,10 +10,10 @@ Type=simple User={{ octavia_system_user_name }} Group={{ octavia_system_group_name }} -{% if program_override is defined %} -ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/octavia/{{ item.value.service_name }}.log +{% if item.value.program_override is defined %} +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 %} -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 %} # Give a reasonable amount of time for the server to start up/shut down diff --git a/templates/octavia-uwsgi.ini.j2 b/templates/octavia-uwsgi.ini.j2 new file mode 100644 index 00000000..76547658 --- /dev/null +++ b/templates/octavia-uwsgi.ini.j2 @@ -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 diff --git a/tests/os_octavia-overrides.yml b/tests/os_octavia-overrides.yml index 7b9e84b4..f04325fb 100644 --- a/tests/os_octavia-overrides.yml +++ b/tests/os_octavia-overrides.yml @@ -86,8 +86,6 @@ octavia_package_state: latest octavia_neutron_management_network_name: lbaas-mgmt octavia_management_net_subnet_cidr: 10.1.7.0/24 -octavia_git_install_branch: stable/ocata - octavia_ssh_enabled: True octavia_amphora_driver: "{% if test_octavia_amphora | bool %}amphora_haproxy_rest_driver{% else %}amphora_noop_driver{% endif %}"