From 060a5beb70a4dbb58fd4b4028036e112e3c4ba63 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 23 Aug 2019 15:41:03 +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/678200/ Depends-On: https://review.opendev.org/678055/ Change-Id: If5aeeefb93c8ba3c1368970de61ea1300218f637 --- defaults/main.yml | 10 ++------- tasks/main.yml | 8 ++++++- tasks/nova_uwsgi.yml | 34 ----------------------------- templates/nova-uwsgi.ini.j2 | 29 ------------------------ tests/ansible-role-requirements.yml | 4 ++++ vars/debian.yml | 5 ----- vars/distro_install.yml | 4 ---- vars/main.yml | 24 +++++++++++++++++++- vars/redhat-7.yml | 5 ----- vars/source_install.yml | 1 - vars/suse.yml | 5 ----- 11 files changed, 36 insertions(+), 93 deletions(-) delete mode 100644 tasks/nova_uwsgi.yml delete mode 100644 templates/nova-uwsgi.ini.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 4be689b4..419617c9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -239,7 +239,6 @@ nova_nested_virt_enabled: False # Uwsgi settings nova_wsgi_processes_max: 16 nova_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, nova_wsgi_processes_max] | min }}" -nova_wsgi_buffer_size: 65535 nova_wsgi_threads: 1 ## Nova libvirt @@ -396,10 +395,8 @@ nova_services: service_name: nova-api-metadata init_config_overrides: "{{ nova_api_metadata_init_overrides }}" start_order: 5 - execstarts: "{{ nova_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-api-metadata.ini" - execreloads: "{{ nova_uwsgi_bin }}/uwsgi --reload /var/run/nova-api-metadata/nova-api-metadata.pid" wsgi_app: True - wsgi_overrides: "{{ nova_api_metadata_uwsgi_ini_overrides }}" + uwsgi_overrides: "{{ nova_api_metadata_uwsgi_ini_overrides }}" uwsgi_bind_address: "{{ nova_metadata_bind_address }}" uwsgi_port: "{{ nova_metadata_port }}" wsgi_name: nova-metadata-wsgi @@ -408,10 +405,8 @@ nova_services: service_name: nova-api-os-compute init_config_overrides: "{{ {'Install': {'Alias': 'nova-api.service'}} | combine(nova_api_os_compute_init_overrides) }}" start_order: 4 - execstarts: "{{ nova_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-api-os-compute.ini" - execreloads: "{{ nova_uwsgi_bin }}/uwsgi --reload /var/run/nova-api-os-compute/nova-api-os-compute.pid" wsgi_app: True - wsgi_overrides: "{{ nova_api_os_compute_uwsgi_ini_overrides }}" + uwsgi_overrides: "{{ nova_api_os_compute_uwsgi_ini_overrides }}" uwsgi_bind_address: "{{ nova_service_bind_address }}" uwsgi_port: "{{ nova_service_port }}" wsgi_name: nova-api-wsgi @@ -480,7 +475,6 @@ nova_pip_packages: - python-novaclient - python-openstackclient - systemd-python - - uWSGI # Specific pip packages provided by the user nova_user_pip_packages: [] diff --git a/tasks/main.yml b/tasks/main.yml index 501075c3..bd9be26a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -180,9 +180,15 @@ tags: - nova-config -- import_tasks: nova_uwsgi.yml +- name: Import uwsgi role + import_role: + name: uwsgi + vars: + uwsgi_services: "{{ uwsgi_nova_services }}" + uwsgi_install_method: "{{ nova_install_method }}" tags: - nova-config + - uwsgi - name: Run the systemd service role import_role: diff --git a/tasks/nova_uwsgi.yml b/tasks/nova_uwsgi.yml deleted file mode 100644 index 19327c21..00000000 --- a/tasks/nova_uwsgi.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -# Copyright 2016, 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: "nova-uwsgi.ini.j2" - dest: "/etc/uwsgi/{{ item.service_name }}.ini" - mode: "0744" - config_overrides: "{{ item.wsgi_overrides }}" - config_type: ini - with_items: "{{ filtered_nova_services }}" - when: item.wsgi_app | default(False) - notify: - - Manage LB - - Restart nova services diff --git a/templates/nova-uwsgi.ini.j2 b/templates/nova-uwsgi.ini.j2 deleted file mode 100644 index 186579ef..00000000 --- a/templates/nova-uwsgi.ini.j2 +++ /dev/null @@ -1,29 +0,0 @@ -# {{ ansible_managed }} -[uwsgi] -uid = {{ nova_system_user_name }} -gid = {{ nova_system_group_name }} - -{% if nova_install_method == 'source' %} -virtualenv = /openstack/venvs/nova-{{ nova_venv_tag }} -{% endif %} -{% if nova_install_method == 'distro' and (ansible_os_family | lower) == 'debian' %} -plugin = python3 -{% endif %} -wsgi-file = {{ nova_bin }}/{{ item.wsgi_name }} -http = {{ item.uwsgi_bind_address}}:{{ item.uwsgi_port }} - -master = true -enable-threads = true -processes = {{ nova_wsgi_processes }} -threads = {{ nova_wsgi_threads }} -exit-on-reload = false -die-on-term = true -lazy-apps = true -add-header = Connection: close -buffer-size = {{ nova_wsgi_buffer_size }} -thunder-lock = true -disable-logging = true -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 b4612180..76cd6045 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -75,3 +75,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 ba368190..b5e1b093 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -43,9 +43,6 @@ nova_service_extra_distro_packages: - nova-compute-kvm novnc: - nova-novncproxy - nova_api: - - uwsgi - - uwsgi-plugin-python3 spice: - nova-spiceproxy serialconsole: @@ -101,5 +98,3 @@ nova_compute_kvm_packages_to_symlink: nova_compute_ksm_packages: - ksmtuned - -nova_uwsgi_bin: '/usr/bin' diff --git a/vars/distro_install.yml b/vars/distro_install.yml index 318db833..653e2e97 100644 --- a/vars/distro_install.yml +++ b/vars/distro_install.yml @@ -20,10 +20,6 @@ # nova_package_list: |- {% set packages = nova_distro_packages %} - {% if nova_services['nova-api-metadata']['group'] in group_names or - nova_services['nova-api-os-compute']['group'] in group_names %} - {% set _ = packages.extend(nova_service_extra_distro_packages['nova_api']) %} - {% endif %} {% if nova_services['nova-novncproxy']['group'] in group_names or nova_services['nova-spicehtml5proxy']['group'] in group_names or nova_services['nova-serialconsole-proxy']['group'] in group_names %} diff --git a/vars/main.yml b/vars/main.yml index 2baac1e7..30f02d44 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -38,13 +38,35 @@ filtered_nova_services: |- {% for key, value in nova_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_nova_services: |- + {% set services = {} %} + {% for key, value in nova_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': nova_bin ~ '/' ~ value.wsgi_name, + 'wsgi_venv': ((nova_install_method == 'source') | ternary(nova_bin | dirname, None)), + 'uwsgi_uid': nova_system_user_name, + 'uwsgi_guid': nova_system_group_name, + 'uwsgi_processes': nova_wsgi_processes, + 'uwsgi_threads': nova_wsgi_threads + } + ) %} + {% set _ = services.update({key: value}) %} + {% endif %} + {% endfor %} + {{ services }} + # Define all Nova mountpoints when using NFS. If defined # the corresponding directory will only be created by the # mount point task. diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 7e8f94dd..ca509187 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -47,9 +47,6 @@ nova_service_extra_distro_packages: - openstack-nova-migration novnc: - openstack-nova-novncproxy - nova_api: - - uwsgi - - uwsgi-plugin-python spice: - openstack-nova-spicehtml5proxy serialconsole: @@ -89,5 +86,3 @@ nova_compute_oslomsg_amqp1_distro_packages: - cyrus-sasl-lib - cyrus-sasl-plain - cyrus-sasl-md5 - -nova_uwsgi_bin: '/usr/sbin' diff --git a/vars/source_install.yml b/vars/source_install.yml index 5c4937bc..b9794119 100644 --- a/vars/source_install.yml +++ b/vars/source_install.yml @@ -37,4 +37,3 @@ nova_package_list: |- {{ packages }} _nova_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin" -nova_uwsgi_bin: "{{ _nova_bin }}" diff --git a/vars/suse.yml b/vars/suse.yml index 2afa5c9d..4ebd97cf 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -46,9 +46,6 @@ nova_service_extra_distro_packages: - openstack-nova-compute novnc: - openstack-nova-novncproxy - nova_api: - - uwsgi - - uwsgi-python spice: [] serialconsole: - openstack-nova-serialproxy @@ -98,5 +95,3 @@ nova_compute_oslomsg_amqp1_distro_packages: - cyrus-sasl - cyrus-sasl-plain - cyrus-sasl-digestmd5 - -nova_uwsgi_bin: '/usr/sbin'