From 4b2724b44bb252758c0f083ca1052b39e87c9462 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 22 Aug 2019 19:27:25 +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: I6f129940e55130c289d94138171cee54dbd28fc1 --- defaults/main.yml | 6 +----- tasks/glance_install.yml | 19 ------------------ tasks/main.yml | 11 +++++++++++ templates/glance-uwsgi.ini.j2 | 30 ----------------------------- tests/ansible-role-requirements.yml | 4 ++++ vars/debian.yml | 4 ---- vars/main.yml | 24 ++++++++++++++++++++++- vars/redhat.yml | 4 ---- vars/source_install.yml | 1 - vars/suse.yml | 4 ---- 10 files changed, 39 insertions(+), 68 deletions(-) delete mode 100644 templates/glance-uwsgi.ini.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 78e11dc0..f311ef0a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -249,7 +249,6 @@ glance_pip_packages: - python-memcached - python-swiftclient - systemd-python - - uwsgi - warlock # Specific pip packages provided by the user @@ -268,13 +267,11 @@ glance_services: service_name: glance-api init_config_overrides: "{{ glance_api_init_overrides }}" start_order: 1 - wsgi_overrides: "{{ glance_api_uwsgi_ini_overrides }}" wsgi_app: True wsgi_name: glance-wsgi-api + uwsgi_overrides: "{{ glance_api_uwsgi_ini_overrides }}" uwsgi_bind_address: "{{ glance_api_bind_address }}" uwsgi_port: "{{ glance_api_service_port }}" - execstarts: "{{ glance_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/glance-api.ini" - execreloads: "{{ glance_uwsgi_bin }}/uwsgi --reload /var/run/glance-api/glance-api.pid" glance-registry: group: glance_registry service_name: glance-registry @@ -287,7 +284,6 @@ glance_services: glance_wsgi_processes_max: 16 glance_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, glance_wsgi_processes_max] | min }}" glance_wsgi_threads: 1 -glance_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/glance_install.yml b/tasks/glance_install.yml index c382ae49..c836d543 100644 --- a/tasks/glance_install.yml +++ b/tasks/glance_install.yml @@ -182,22 +182,3 @@ tags: - glance-config - systemd-service - -- name: Ensure uWSGI directory exists - file: - path: "/etc/uwsgi/" - state: directory - mode: "0711" - -- name: Apply uWSGI configuration - config_template: - src: "glance-uwsgi.ini.j2" - dest: "/etc/uwsgi/{{ item.service_name }}.ini" - mode: "0744" - config_overrides: "{{ item.wsgi_overrides }}" - config_type: ini - with_items: "{{ filtered_glance_services }}" - when: item.wsgi_app | default(False) - notify: - - Manage LB - - Restart glance services diff --git a/tasks/main.yml b/tasks/main.yml index f9b7e0ca..f8e47a37 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -122,6 +122,17 @@ tags: - glance-config +- name: Import uwsgi role + import_role: + name: uwsgi + vars: + uwsgi_services: "{{ uwsgi_glance_services }}" + uwsgi_install_method: "{{ glance_install_method }}" + tags: + - glance-install + - glance-config + - uwsgi + - name: Import ceph_client role import_role: name: ceph_client diff --git a/templates/glance-uwsgi.ini.j2 b/templates/glance-uwsgi.ini.j2 deleted file mode 100644 index 94eb3506..00000000 --- a/templates/glance-uwsgi.ini.j2 +++ /dev/null @@ -1,30 +0,0 @@ -[uwsgi] -uid = {{ glance_system_user_name }} -gid = {{ glance_system_group_name }} - -{% if glance_install_method == 'source' %} -virtualenv = /openstack/venvs/glance-{{ glance_venv_tag }} -{% endif %} -{% if glance_install_method == 'distro' and (ansible_os_family | lower) == 'debian' %} -plugin = python3 -{% endif %} -wsgi-file = {{ glance_bin }}/{{ item.wsgi_name }} -http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} - -master = true -enable-threads = true -processes = {{ glance_wsgi_processes }} -threads = {{ glance_wsgi_threads }} -exit-on-reload = true -die-on-term = true -lazy-apps = true -add-header = Connection: close -buffer-size = {{ glance_wsgi_buffer_size }} -thunder-lock = true -disable-logging = true -http-auto-chunked = true -http-raw-body = true -socket-timeout = 10 - -# 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 8961a500..08a0a50a 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -63,3 +63,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 b8816632..e8dc31d0 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -31,11 +31,7 @@ glance_devel_distro_packages: glance_service_distro_packages: - python3-glance - python3-systemd - - uwsgi - - uwsgi-plugin-python3 glance_oslomsg_amqp1_distro_packages: - libsasl2-modules - sasl2-bin - -glance_uwsgi_bin: '/usr/bin' diff --git a/vars/main.yml b/vars/main.yml index ec1689c2..a9697b8e 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -23,13 +23,35 @@ filtered_glance_services: |- {% for key, value in glance_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_glance_services: |- + {% set services = {} %} + {% for key, value in glance_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': glance_bin ~ '/' ~ value.wsgi_name, + 'wsgi_venv': ((glance_install_method == 'source') | ternary(glance_bin | dirname, None)), + 'uwsgi_uid': glance_system_user_name, + 'uwsgi_guid': glance_system_group_name, + 'uwsgi_processes': glance_wsgi_processes, + 'uwsgi_threads': glance_wsgi_threads, + } + ) %} + {% set _ = services.update({key: value}) %} + {% endif %} + {% endfor %} + {{ services }} + # Define all glance mountpoints when using NFS. If defined # the corresponding directory will only be created by the # mount point task. diff --git a/vars/redhat.yml b/vars/redhat.yml index b86a2b9c..110fe4ff 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -27,16 +27,12 @@ glance_devel_distro_packages: glance_service_distro_packages: - openstack-glance - systemd-python - - uwsgi - - uwsgi-plugin-python glance_oslomsg_amqp1_distro_packages: - cyrus-sasl-lib - cyrus-sasl-plain - cyrus-sasl-md5 -glance_uwsgi_bin: '/usr/sbin' - glance_core_files: - tmp_f: "/tmp/policy.json" target_f: "{{ glance_etc_dir }}/policy.json" diff --git a/vars/source_install.yml b/vars/source_install.yml index 3aa73c3b..f3a61c47 100644 --- a/vars/source_install.yml +++ b/vars/source_install.yml @@ -21,4 +21,3 @@ glance_package_list: |- {{ packages }} _glance_bin: "/openstack/venvs/glance-{{ glance_venv_tag }}/bin" -glance_uwsgi_bin: "{{ _glance_bin }}" diff --git a/vars/suse.yml b/vars/suse.yml index 3f1f891e..40d736b4 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -29,12 +29,8 @@ glance_service_distro_packages: - openstack-glance - openstack-glance-api - python-systemd - - uwsgi - - uwsgi-python glance_oslomsg_amqp1_distro_packages: - cyrus-sasl - cyrus-sasl-plain - cyrus-sasl-digestmd5 - -glance_uwsgi_bin: '/usr/sbin'