Start using uWSGI role

Move service to use uWSGI role instead of iternal task for uwsgi
deployment. This aims to ease the maintenance of uWSGI and speedup
metal deployments as the same uwsgi environment will be used
across all services.

Depends-On: https://review.opendev.org/678025/
Change-Id: Ieac6d03a436f6b706d7f12e292ffc98171a43246
This commit is contained in:
Dmitriy Rabotyagov 2019-08-23 14:28:35 +03:00
parent 4dd7251f8c
commit ee018d9083
10 changed files with 37 additions and 83 deletions

View File

@ -296,7 +296,6 @@ cinder_pip_packages:
- python-openstackclient
- python-memcached
- systemd-python
- uwsgi
# Specific pip packages provided by the user
cinder_user_pip_packages: []
@ -338,11 +337,9 @@ cinder_services:
service_name: cinder-api
init_config_overrides: "{{ cinder_api_init_overrides }}"
start_order: 4
execstarts: "{{ cinder_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/cinder-api.ini"
execreloads: "{{ cinder_uwsgi_bin }}/uwsgi --reload /var/run/cinder-api/cinder-api.pid"
wsgi_overrides: "{{ cinder_api_uwsgi_ini_overrides }}"
wsgi_app: True
wsgi_name: cinder-wsgi
uwsgi_overrides: "{{ cinder_api_uwsgi_ini_overrides }}"
uwsgi_port: "{{ cinder_service_port }}"
uwsgi_bind_address: "{{ cinder_uwsgi_bind_address }}"
@ -350,7 +347,6 @@ cinder_services:
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

View File

@ -1,33 +0,0 @@
---
# 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:
- Manage LB
- Restart cinder services

View File

@ -135,9 +135,15 @@
tags:
- cinder-config
- import_tasks: cinder_uwsgi.yml
- name: Import uwsgi role
import_role:
name: uwsgi
vars:
uwsgi_services: "{{ uwsgi_cinder_services }}"
uwsgi_install_method: "{{ cinder_install_method }}"
tags:
- cinder-config
- uwsgi
- import_tasks: service_setup.yml
vars:

View File

@ -1,28 +0,0 @@
[uwsgi]
uid = {{ cinder_system_user_name }}
gid = {{ cinder_system_group_name }}
{% if cinder_install_method == 'source' %}
virtualenv = /openstack/venvs/cinder-{{ cinder_venv_tag }}
{% endif %}
{% if cinder_install_method == 'distro' and (ansible_os_family | lower) == 'debian' %}
plugin = python3
{% endif %}
wsgi-file = {{ cinder_bin }}/{{ item.wsgi_name }}
http = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }}
master = true
enable-threads = true
processes = {{ cinder_wsgi_processes }}
threads = {{ cinder_wsgi_threads }}
exit-on-reload = false
die-on-term = true
lazy-apps = true
add-header = Connection: close
buffer-size = {{ cinder_wsgi_buffer_size }}
thunder-lock = true
logfile-chmod = 644
pidfile = /var/run/{{ item.service_name }}/{{ item.service_name }}.pid
# Avoid filling up the logs with health check requests from haproxy.
route-user-agent = ^osa-haproxy-healthcheck$ donotlog:

View File

@ -59,3 +59,7 @@
src: https://opendev.org/openstack/ansible-role-python_venv_build
scm: git
version: master
- name: uwsgi
src: https://opendev.org/openstack/ansible-role-uwsgi
scm: git
version: master

View File

@ -45,9 +45,7 @@ cinder_devel_distro_packages:
- libxslt1-dev
- libsystemd-dev
cinder_api_distro_packages:
- uwsgi
- uwsgi-plugin-python3
cinder_api_distro_packages: []
cinder_volume_distro_packages: []
@ -72,5 +70,3 @@ cinder_backup_distro_packages:
cinder_oslomsg_amqp1_distro_packages:
- libsasl2-modules
- sasl2-bin
cinder_uwsgi_bin: '/usr/bin'

View File

@ -28,13 +28,35 @@ filtered_cinder_services: |-
{% for key, value in cinder_services.items() %}
{% if (value['group'] in group_names) and
(('condition' not in value) or
('condition' in value and value['condition'])) %}
('condition' in value and value['condition'])) and
not ('wsgi_app' in value and value['wsgi_app']) %}
{% set _ = value.update({'service_key': key}) %}
{% set _ = services.append(value) %}
{% endif %}
{% endfor %}
{{ services | sort(attribute='start_order') }}
uwsgi_cinder_services: |-
{% set services = {} %}
{% for key, value in cinder_services.items() %}
{% if (value['group'] in group_names) and
(('condition' not in value) or ('condition' in value and value['condition']))
and ('wsgi_app' in value and value['wsgi_app']) %}
{% set _ = value.update(
{
'wsgi_path': cinder_bin ~ '/' ~ value.wsgi_name,
'wsgi_venv': ((cinder_install_method == 'source') | ternary(cinder_bin | dirname, None)),
'uwsgi_uid': cinder_system_user_name,
'uwsgi_guid': cinder_system_group_name,
'uwsgi_processes': cinder_wsgi_processes,
'uwsgi_threads': cinder_wsgi_threads
}
) %}
{% set _ = services.update({key: value}) %}
{% endif %}
{% endfor %}
{{ services }}
cinder_core_files:
- tmp_f: "/tmp/api-paste.ini"
target_f: "/etc/cinder/api-paste.ini"

View File

@ -37,9 +37,7 @@ cinder_devel_distro_packages:
- systemd-devel
- zlib-devel
cinder_api_distro_packages:
- uwsgi
- uwsgi-plugin-python
cinder_api_distro_packages: []
cinder_volume_distro_packages: []
@ -64,5 +62,3 @@ cinder_oslomsg_amqp1_distro_packages:
- cyrus-sasl-lib
- cyrus-sasl-plain
- cyrus-sasl-md5
cinder_uwsgi_bin: '/usr/sbin'

View File

@ -32,4 +32,3 @@ cinder_package_list: |-
{{ packages }}
_cinder_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin"
cinder_uwsgi_bin: "{{ _cinder_bin }}"

View File

@ -30,8 +30,6 @@ cinder_service_distro_packages:
cinder_api_distro_packages:
- openstack-cinder-api
- uwsgi
- uwsgi-python
cinder_devel_distro_packages:
- git-core
@ -66,5 +64,3 @@ cinder_oslomsg_amqp1_distro_packages:
- cyrus-sasl
- cyrus-sasl-plain
- cyrus-sasl-digestmd5
cinder_uwsgi_bin: '/usr/sbin'