placement: Add support for using uWSGI

Needed to set log_file because logs ended up with following name:
<frozen importlib._bootstrap>.log

Change-Id: I706adef8efbd44e6d9f82f67f5a3cdb529f02fff
This commit is contained in:
Michal Nasiadka 2024-12-10 11:32:47 +01:00
parent 6eb6fee6ee
commit 454dc2a952
5 changed files with 41 additions and 5 deletions

View File

@ -8,6 +8,7 @@ placement_services:
volumes: "{{ placement_api_default_volumes + placement_api_extra_volumes }}" volumes: "{{ placement_api_default_volumes + placement_api_extra_volumes }}"
dimensions: "{{ placement_api_dimensions }}" dimensions: "{{ placement_api_dimensions }}"
healthcheck: "{{ placement_api_healthcheck }}" healthcheck: "{{ placement_api_healthcheck }}"
wsgi: "placement.wsgi.api:application"
haproxy: haproxy:
placement_api: placement_api:
enabled: "{{ enable_placement }}" enabled: "{{ enable_placement }}"
@ -148,3 +149,8 @@ placement_ks_users:
placement_enable_tls_backend: "{{ kolla_enable_tls_backend }}" placement_enable_tls_backend: "{{ kolla_enable_tls_backend }}"
placement_copy_certs: "{{ kolla_copy_ca_into_containers | bool or placement_enable_tls_backend | bool }}" placement_copy_certs: "{{ kolla_copy_ca_into_containers | bool or placement_enable_tls_backend | bool }}"
####################
# WSGI
####################
placement_wsgi_provider: "uwsgi"

View File

@ -63,11 +63,32 @@
src: "{{ item }}" src: "{{ item }}"
dest: "{{ node_config_directory }}/placement-api/placement-api-wsgi.conf" dest: "{{ node_config_directory }}/placement-api/placement-api-wsgi.conf"
mode: "0660" mode: "0660"
when: service | service_enabled_and_mapped_to_host when:
- service | service_enabled_and_mapped_to_host
- placement_wsgi_provider == "apache"
with_first_found: with_first_found:
- "{{ node_custom_config }}/placement/{{ inventory_hostname }}/placement-api-wsgi.conf" - "{{ node_custom_config }}/placement/{{ inventory_hostname }}/placement-api-wsgi.conf"
- "{{ node_custom_config }}/placement/placement-api-wsgi.conf" - "{{ node_custom_config }}/placement/placement-api-wsgi.conf"
- "placement-api-wsgi.conf.j2" - "placement-api-wsgi.conf.j2"
notify:
- "Restart placement-api container"
- name: "Configure uWSGI for Placement"
include_role:
name: service-uwsgi-config
vars:
project_services: "{{ placement_services }}"
service: "{{ placement_services['placement-api'] }}"
service_name: "placement-api"
service_uwsgi_config_http_port: "{{ placement_api_listen_port }}"
service_uwsgi_config_module: "{{ service.wsgi }}"
service_uwsgi_config_tls_backend: "{{ placement_enable_tls_backend | bool }}"
service_uwsgi_config_tls_cert: "/etc/placement/certs/placement-cert.pem"
service_uwsgi_config_tls_key: "/etc/placement/certs/placement-key.pem"
service_uwsgi_config_uid: "placement"
when:
- service | service_enabled_and_mapped_to_host
- placement_wsgi_provider == "uwsgi"
- name: Copying over migrate-db.rc.j2 configuration - name: Copying over migrate-db.rc.j2 configuration
become: true become: true

View File

@ -1,7 +1,8 @@
{% set apache_binary = 'apache2' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd' %} {% set apache_binary = 'apache2' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd' %}
{% set apache_conf_dir = 'apache2/conf-enabled' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd/conf.d' %} {% set apache_conf_dir = 'apache2/conf-enabled' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd/conf.d' %}
{% set command = '/usr/sbin/{{ apache_binary }} -DFOREGROUND' if placement_wsgi_provider == 'apache' else 'uwsgi /etc/placement/placement-api-uwsgi.ini' %}
{ {
"command": "/usr/sbin/{{ apache_binary }} -DFOREGROUND", "command": "{{ command }}",
"config_files": [ "config_files": [
{ {
"source": "{{ container_config_directory }}/placement.conf", "source": "{{ container_config_directory }}/placement.conf",
@ -14,13 +15,19 @@
"dest": "/etc/placement/{{ placement_policy_file }}", "dest": "/etc/placement/{{ placement_policy_file }}",
"owner": "placement", "owner": "placement",
"perm": "0600" "perm": "0600"
}{% endif %}, }{% endif %}{% if placement_wsgi_provider == 'apache' %},
{ {
"source": "{{ container_config_directory }}/placement-api-wsgi.conf", "source": "{{ container_config_directory }}/placement-api-wsgi.conf",
"dest": "/etc/{{ apache_conf_dir }}/00-placement-api.conf", "dest": "/etc/{{ apache_conf_dir }}/00-placement-api.conf",
"owner": "placement", "owner": "placement",
"perm": "0600" "perm": "0600"
}, }{% elif placement_wsgi_provider == 'uwsgi' %},
{
"source": "{{ container_config_directory }}/placement-api-uwsgi.ini",
"dest": "/etc/placement/placement-api-uwsgi.ini",
"owner": "placement",
"perm": "0600"
}{% endif %},
{ {
"source": "{{ container_config_directory }}/migrate-db.rc", "source": "{{ container_config_directory }}/migrate-db.rc",
"dest": "/etc/placement/migrate-db.rc", "dest": "/etc/placement/migrate-db.rc",

View File

@ -1,7 +1,7 @@
[DEFAULT] [DEFAULT]
debug = {{ placement_logging_debug }} debug = {{ placement_logging_debug }}
log_dir = /var/log/kolla/placement log_file = /var/log/kolla/placement/{{ service_name }}.log
state_path = /var/lib/placement state_path = /var/lib/placement

View File

@ -11,3 +11,5 @@ features:
- Variable - Variable
* - Nova * - Nova
- nova_wsgi_provider - nova_wsgi_provider
* - Placement
- placement_wsgi_provider