diff --git a/defaults/main.yml b/defaults/main.yml index 90f9b756..c86ce248 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -44,6 +44,7 @@ cinder_default_availability_zone: "{{ cinder_storage_availability_zone }}" cinder_storage_address: 127.0.0.1 cinder_management_address: 127.0.0.1 +cinder_uwsgi_bind_address: 0.0.0.0 cinder_nova_catalog_info: compute:nova:internalURL cinder_nova_catalog_admin_info: compute:nova:adminURL @@ -258,6 +259,7 @@ cinder_pip_packages: - python-cinderclient - python-keystoneclient - python-memcached + - uwsgi cinder_api_init_overrides: {} cinder_scheduler_init_overrides: {} @@ -271,6 +273,13 @@ cinder_services: service_name: cinder-api init_config_overrides: "{{ cinder_api_init_overrides }}" start_order: 1 + wsgi_overrides: "{{ cinder_api_uwsgi_ini_overrides }}" + wsgi_app: True + log_string: "--logto " + wsgi_name: cinder-wsgi + uwsgi_port: "{{ cinder_service_port }}" + uwsgi_bind_address: "{{ cinder_uwsgi_bind_address }}" + program_override: "{{ cinder_bin }}/uwsgi --ini /etc/uwsgi/cinder-api.ini" cinder-scheduler: group: cinder_scheduler service_name: cinder-scheduler @@ -288,6 +297,12 @@ cinder_services: init_config_overrides: "{{ cinder_backup_init_overrides }}" start_order: 4 +# Cinder uWSGI settings +cinder_wsgi_processes_max: 16 +cinder_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, cinder_wsgi_processes_max] | min }}" +cinder_wsgi_threads: 1 +cinder_wsgi_buffer_size: 65535 + # This variable is used by the repo_build process to determine # which host group to check for members of before building the # pip packages required by this role. The value is picked up @@ -314,5 +329,6 @@ cinder_policy_overrides: {} cinder_rootwrap_conf_overrides: {} cinder_api_paste_ini_overrides: {} cinder_cinder_conf_overrides: {} +cinder_api_uwsgi_ini_overrides: {} _UUID_regex: "[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}" diff --git a/releasenotes/notes/cinder_uwsgi-c6a1651a4c54a8cc.yaml b/releasenotes/notes/cinder_uwsgi-c6a1651a4c54a8cc.yaml new file mode 100644 index 00000000..f425d9a1 --- /dev/null +++ b/releasenotes/notes/cinder_uwsgi-c6a1651a4c54a8cc.yaml @@ -0,0 +1,15 @@ +--- +features: + - The ``cinder-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 + ``cinder_wsgi_processes_max``, + ``cinder_wsgi_processes``, ``cinder_wsgi_threads``, + and ``cinder_wsgi_buffer_size``. + Additionally, you can override any settings in the + uWSGI ini configuration file using the + ``cinder_api_uwsgi_ini_overrides`` setting. + The uWSGI application will listen on the address + specified by ``cinder_uwsgi_bind_address`` which + defaults to ``0.0.0.0``. diff --git a/tasks/cinder_uwsgi.yml b/tasks/cinder_uwsgi.yml new file mode 100644 index 00000000..c0a70562 --- /dev/null +++ b/tasks/cinder_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: "cinder-uwsgi.ini.j2" + dest: "/etc/uwsgi/{{ item.service_name }}.ini" + mode: "0744" + config_overrides: "{{ item.wsgi_overrides }}" + config_type: ini + with_items: "{{ filtered_cinder_services }}" + when: item.wsgi_app | default(False) + notify: + - Restart cinder services diff --git a/tasks/main.yml b/tasks/main.yml index b8b843c3..fa81278e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -59,6 +59,10 @@ tags: - cinder-config +- include: cinder_uwsgi.yml + tags: + - cinder-config + - include: cinder_service_setup.yml static: no when: diff --git a/templates/cinder-systemd-init.j2 b/templates/cinder-systemd-init.j2 index 9a044faf..d736bfab 100644 --- a/templates/cinder-systemd-init.j2 +++ b/templates/cinder-systemd-init.j2 @@ -10,10 +10,10 @@ Type=simple User={{ cinder_system_user_name }} Group={{ cinder_system_group_name }} -{% if program_override is defined %} -ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/cinder/{{ item.service_name }}.log +{% if item.program_override is defined %} +ExecStart={{ item.program_override }} {{ item.program_config_options|default('') }} {{ item.log_string | default('--log-file=') }}/var/log/cinder/{{ item.service_name }}.log {% else %} -ExecStart={{ cinder_bin }}/{{ item.service_name }} {{ program_config_options|default('') }} --log-file=/var/log/cinder/{{ item.service_name }}.log +ExecStart={{ cinder_bin }}/{{ item.service_name }} {{ item.program_config_options|default('') }} --log-file=/var/log/cinder/{{ item.service_name }}.log {% endif %} {% if item.service_name != "cinder-api" %} ExecReload=/bin/kill -HUP $MAINPID diff --git a/templates/cinder-uwsgi.ini.j2 b/templates/cinder-uwsgi.ini.j2 new file mode 100644 index 00000000..20ba1abc --- /dev/null +++ b/templates/cinder-uwsgi.ini.j2 @@ -0,0 +1,19 @@ +[uwsgi] +uid = {{ cinder_system_user_name }} +gid = {{ cinder_system_group_name }} + +virtualenv = /openstack/venvs/cinder-{{ cinder_venv_tag }} +wsgi-file = {{ cinder_bin }}/{{ item.wsgi_name }} +http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} + +master = true +enable-threads = true +processes = {{ cinder_wsgi_processes }} +threads = {{ cinder_wsgi_threads }} +exit-on-reload = true +die-on-term = true +lazy-apps = true +add-header = Connection: close +buffer-size = {{ cinder_wsgi_buffer_size }} +thunder-lock = true +logfile-chmod = 644