From c9d10f41fad8bcee0f3604727007b8034a7fa67f Mon Sep 17 00:00:00 2001 From: Damian Dabrowski Date: Mon, 17 Apr 2023 17:00:53 +0200 Subject: [PATCH] Add uWSGI support to blazar This patch adds uWSGI support to os_blazar role. All openstack services should stay behind uWSGI. It's also required for upcoming TLS backend feature. Blazar does not have native TLS support so it needs to be handled by uWSGI. Change-Id: I65511de4d5014a28f0f91536f9dbaf96fcb8e7a2 --- defaults/main.yml | 13 +++++++++- .../notes/uwsgi-support-70d9427de86555eb.yaml | 4 ++++ tasks/blazar_post_install.yml | 1 + tasks/main.yml | 10 ++++++++ vars/main.yml | 24 ++++++++++++++++++- 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/uwsgi-support-70d9427de86555eb.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 6b99b7c..64955e7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -93,9 +93,13 @@ blazar_services: blazar-api: group: blazar_all service_name: blazar-api - execstarts: "{{ blazar_bin }}/blazar-api {{ blazar_config_option }}" init_config_overrides: "{{ blazar_api_init_config_overrides }}" start_order: 1 + wsgi_app: True + wsgi_name: blazar-api-wsgi + uwsgi_port: "{{ blazar_service_port }}" + uwsgi_bind_address: "{{ blazar_bind_address }}" + uwsgi_overrides: "{{ blazar_api_uwsgi_ini_overrides }}" blazar-manager: group: blazar_all service_name: blazar-manager @@ -103,6 +107,12 @@ blazar_services: init_config_overrides: "{{ blazar_manager_init_config_overrides }}" start_order: 2 +# Blazar uWSGI settings +blazar_wsgi_processes_max: 16 +blazar_wsgi_processes: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2, blazar_wsgi_processes_max] | min }}" +blazar_wsgi_threads: 1 +blazar_wsgi_buffer_size: 65535 + ## Keystone blazar_service_project_domain_id: default blazar_service_project_name: service @@ -156,3 +166,4 @@ blazar_policy_overrides: {} blazar_blazar_conf_overrides: {} blazar_api_init_config_overrides: {} blazar_manager_init_config_overrides: {} +blazar_api_uwsgi_ini_overrides: {} diff --git a/releasenotes/notes/uwsgi-support-70d9427de86555eb.yaml b/releasenotes/notes/uwsgi-support-70d9427de86555eb.yaml new file mode 100644 index 0000000..ed1c677 --- /dev/null +++ b/releasenotes/notes/uwsgi-support-70d9427de86555eb.yaml @@ -0,0 +1,4 @@ +--- +other: + - | + uWSGI support was implemented to os_blazar role. diff --git a/tasks/blazar_post_install.yml b/tasks/blazar_post_install.yml index 3ff7c6c..5951ab1 100644 --- a/tasks/blazar_post_install.yml +++ b/tasks/blazar_post_install.yml @@ -36,3 +36,4 @@ condition: "{{ (blazar_policy_overrides) }}" notify: - Restart blazar services + - Restart uwsgi services diff --git a/tasks/main.yml b/tasks/main.yml index 8a3e323..30d6cc7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -103,6 +103,16 @@ tags: - blazar-config +- name: Import uwsgi role + import_role: + name: uwsgi + vars: + uwsgi_services: "{{ uwsgi_blazar_services }}" + uwsgi_install_method: "source" + tags: + - blazar-config + - uwsgi + - name: Run the systemd service role import_role: name: systemd_service diff --git a/vars/main.yml b/vars/main.yml index 62f4dc0..08dc456 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -25,7 +25,8 @@ filtered_blazar_services: |- {% for key, value in blazar_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, @@ -40,3 +41,24 @@ filtered_blazar_services: |- {% endif %} {% endfor %} {{ services | sort(attribute='start_order') }} + +uwsgi_blazar_services: |- + {% set services = {} %} + {% for key, value in blazar_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': blazar_bin ~ '/' ~ value.wsgi_name, + 'wsgi_venv': "{{ blazar_bin | dirname }}", + 'uwsgi_uid': blazar_system_user_name, + 'uwsgi_guid': blazar_system_group_name, + 'uwsgi_processes': blazar_wsgi_processes, + 'uwsgi_threads': blazar_wsgi_threads + } + ) %} + {% set _ = services.update({key: value}) %} + {% endif %} + {% endfor %} + {{ services }}