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.

Change-Id: Iec03bd79279e694678336880460bcb83f68d9780
This commit is contained in:
Dmitriy Rabotyagov 2019-09-04 16:25:51 +03:00
parent 6eaddb9daa
commit b7a76fb341
7 changed files with 51 additions and 55 deletions

View File

@ -134,8 +134,11 @@ gnocchi_services:
service_name: "gnocchi-api"
service_enabled: true
init_config_overrides: "{{ gnocchi_api_init_overrides }}"
execstarts: "{{ gnocchi_bin }}/uwsgi --autoload --ini /etc/uwsgi/gnocchi-api.ini"
execreloads: "{{ gnocchi_bin }}/uwsgi --reload /var/run/gnocchi-api/gnocchi-api.pid"
wsgi_app: True
wsgi_path: "{{ gnocchi_bin }}/gnocchi-api"
uwsgi_bind_address: "{{ gnocchi_service_address }}"
uwsgi_port: "{{ gnocchi_service_port }}"
uwsgi_overrides: "{{ gnocchi_uwsgi_conf_overrides }}"
gnocchi-metricd:
group: "gnocchi_metricd"
service_name: "gnocchi-metricd"
@ -153,7 +156,6 @@ gnocchi_pip_packages:
- kazoo
- redis
- systemd-python
- uwsgi
# This variable is used by the repo_build process to determine
# which host group to check for members of before building the

View File

@ -15,14 +15,14 @@
- name: Stop services
service:
name: "{{ item.value.service_name }}"
name: "{{ item.service_name }}"
enabled: yes
state: "stopped"
daemon_reload: yes
with_dict: "{{ gnocchi_services }}"
with_items: "{{ filtered_gnocchi_services }}"
when:
- "item.value.group in group_names"
- item.value.service_enabled | bool
- "item.group in group_names"
- item.service_enabled | bool
register: _stop
until: _stop is success
retries: 5
@ -53,14 +53,14 @@
- name: Start services
service:
name: "{{ item.value.service_name }}"
name: "{{ item.service_name }}"
enabled: yes
state: "started"
daemon_reload: yes
with_dict: "{{ gnocchi_services }}"
with_items: "{{ filtered_gnocchi_services }}"
when:
- "item.value.group in group_names"
- item.value.service_enabled | bool
- "item.group in group_names"
- item.service_enabled | bool
register: _start
until: _start is success
retries: 5

View File

@ -47,26 +47,9 @@
content: "{{ gnocchi_policy_user_content | default(gnocchi_policy_default_content, true) }}"
notify:
- Restart gnocchi services
- Restart uwsgi services
- Restart web server
- name: Configurng uWSGI
block:
- name: Ensure uWSGI directory exists
file:
path: "/etc/uwsgi/"
state: directory
mode: "0711"
- name: Apply uWSGI configuration
config_template:
src: "gnocchi-uwsgi.ini.j2"
dest: "/etc/uwsgi/gnocchi-api.ini"
mode: "0644"
config_overrides: "{{ gnocchi_uwsgi_conf_overrides }}"
config_type: ini
notify:
- Restart gnocchi services
when: "'gnocchi_api' in group_names"
# NOTE(noonedeadpunk): This task is created due to migration from apache to uwsgi
# which was introduced during train release. It can be dropped afterwards.
- name: Drop Apache related configs

View File

@ -83,6 +83,16 @@
- gnocchi-config
- systemd-service
- name: Import uwsgi role
import_role:
name: uwsgi
vars:
uwsgi_services: "{{ uwsgi_gnocchi_services }}"
uwsgi_install_method: "source"
tags:
- gnocchi-config
- uwsgi
- import_tasks: service_setup.yml
vars:
_service_adminuri_insecure: "{{ keystone_service_adminuri_insecure }}"

View File

@ -1,25 +0,0 @@
[uwsgi]
uid = {{ gnocchi_system_user_name }}
gid = {{ gnocchi_system_group_name }}
virtualenv = /openstack/venvs/gnocchi-{{ gnocchi_venv_tag }}
wsgi-file = {{ gnocchi_bin }}/gnocchi-api
http-socket = {{ gnocchi_service_address }}:{{ gnocchi_service_port }}
master = true
enable-threads = true
processes = {{ gnocchi_wsgi_processes }}
threads = {{ gnocchi_wsgi_threads }}
exit-on-reload = true
die-on-term = true
lazy-apps = true
add-header = Connection: close
buffer-size = 65535
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:

View File

@ -58,3 +58,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

@ -28,7 +28,8 @@ filtered_gnocchi_services: |-
{% for name, service in gnocchi_services.items() %}
{% if (service['group'] in group_names) and
(('service_enabled' not in service) or
('service_enabled' in service and service['service_enabled'])) %}
('service_enabled' in service and service['service_enabled']))
and not ('wsgi_app' in service and service['wsgi_app']) %}
{% set _ = service.update(
{
'service_key': name,
@ -48,3 +49,24 @@ filtered_gnocchi_services: |-
{% endif %}
{% endfor %}
{{ services }}
uwsgi_gnocchi_services: |-
{% set services = {} %}
{% for name, service in gnocchi_services.items() %}
{% if (service['group'] in group_names) and
(('service_enabled' not in service) or
('service_enabled' in service and service['service_enabled']))
and ('wsgi_app' in service and service['wsgi_app']) %}
{% set _ = service.update(
{
'wsgi_venv': gnocchi_bin | dirname,
'uwsgi_uid': gnocchi_system_user_name,
'uwsgi_guid': gnocchi_system_group_name,
'uwsgi_processes': gnocchi_wsgi_processes,
'uwsgi_threads': gnocchi_wsgi_threads,
}
) %}
{% set _ = services.update({name: service}) %}
{% endif %}
{% endfor %}
{{ services }}