From ee018d90838e03b1ed413a7667b060c6baf438c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 23 Aug 2019 14:28:35 +0300 Subject: [PATCH] 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 --- defaults/main.yml | 6 +----- tasks/cinder_uwsgi.yml | 33 ----------------------------- tasks/main.yml | 8 ++++++- templates/cinder-uwsgi.ini.j2 | 28 ------------------------ tests/ansible-role-requirements.yml | 4 ++++ vars/debian.yml | 6 +----- vars/main.yml | 24 ++++++++++++++++++++- vars/redhat.yml | 6 +----- vars/source_install.yml | 1 - vars/suse.yml | 4 ---- 10 files changed, 37 insertions(+), 83 deletions(-) delete mode 100644 tasks/cinder_uwsgi.yml delete mode 100644 templates/cinder-uwsgi.ini.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 3a68956f..ef8c6108 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/tasks/cinder_uwsgi.yml b/tasks/cinder_uwsgi.yml deleted file mode 100644 index d18f7ea0..00000000 --- a/tasks/cinder_uwsgi.yml +++ /dev/null @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 9b07c58e..8088430d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: diff --git a/templates/cinder-uwsgi.ini.j2 b/templates/cinder-uwsgi.ini.j2 deleted file mode 100644 index 4f1fcda9..00000000 --- a/templates/cinder-uwsgi.ini.j2 +++ /dev/null @@ -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: diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index a8dea176..92969713 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -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 diff --git a/vars/debian.yml b/vars/debian.yml index 9940c423..0a15daa0 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -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' diff --git a/vars/main.yml b/vars/main.yml index a44bd876..b4581149 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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" diff --git a/vars/redhat.yml b/vars/redhat.yml index 4f15beff..485a439d 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -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' diff --git a/vars/source_install.yml b/vars/source_install.yml index a63c5748..1d161408 100644 --- a/vars/source_install.yml +++ b/vars/source_install.yml @@ -32,4 +32,3 @@ cinder_package_list: |- {{ packages }} _cinder_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin" -cinder_uwsgi_bin: "{{ _cinder_bin }}" diff --git a/vars/suse.yml b/vars/suse.yml index 63c7cd61..1eaf5483 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -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'