Implement uWSGI for glance-api

As part of the Pike goals we are moving api services to run as WSGI
apps. glance-api service is set up as a wsgi app, and this patch moves
it over.

Since this is just a drop in replacement for the existing eventlet
service operators and deployers should notice no difference.

Implements: blueprint goal-deploy-api-in-wsgi
Change-Id: Ie5fbf437031be01682534c466b3737d090a81c57
This commit is contained in:
Andy McCrae 2017-07-21 13:38:15 +01:00
parent c2e384eabf
commit 8c2f4b0b7c
6 changed files with 84 additions and 2 deletions

View File

@ -218,6 +218,7 @@ glance_pip_packages:
- python-keystoneclient
- python-memcached
- python-swiftclient
- uwsgi
- warlock
glance_api_init_overrides: {}
@ -230,12 +231,25 @@ 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
log_string: "--logto "
wsgi_name: glance-wsgi-api
uwsgi_bind_address: "{{glance_api_bind_address }}"
uwsgi_port: "{{ glance_api_service_port }}"
program_override: "{{ glance_bin }}/uwsgi --ini /etc/uwsgi/glance-api.ini"
glance-registry:
group: glance_registry
service_name: glance-registry
init_config_overrides: "{{ glance_registry_init_overrides }}"
start_order: 2
# Glance uWSGI settings
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
# pip packages required by this role. The value is picked up
@ -253,3 +267,4 @@ glance_glance_scrubber_conf_overrides: {}
glance_glance_scheme_json_overrides: {}
glance_glance_swift_store_conf_overrides: {}
glance_policy_overrides: {}
glance_api_uwsgi_ini_overrides: {}

View File

@ -0,0 +1,12 @@
---
features:
- The ``glance-api`` service has moved to run as a
uWSGI application. You can set the max number of WSGI
processes, the number of processes, threads, and
buffer size utilizing the
``glance_wsgi_processes_max``,
``glance_wsgi_processes``, ``glance_wsgi_threads``,
and ``glance_wsgi_buffer_size``.
Additionally, you can override any settings in the
uWSGI ini configuration file using the
``glance_api_uwsgi_ini_overrides`` setting.

32
tasks/glance_uwsgi.yml Normal file
View File

@ -0,0 +1,32 @@
---
# Copyright 2017, 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: "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:
- Restart glance services

View File

@ -49,6 +49,10 @@
tags:
- glance-config
- include: glance_uwsgi.yml
tags:
- glance-config
- include: glance_service_setup.yml
static: no
when:

View File

@ -11,9 +11,9 @@ User={{ glance_system_user_name }}
Group={{ glance_system_group_name }}
{% if program_override is defined %}
ExecStart={{ program_override }} {{ program_config_options | default('') }} --log-file=/var/log/glance/{{ item.service_name }}.log
ExecStart={{ item.program_override }} {{ item.program_config_options | default('') }} {{ item.log_string | default('--log-file=') }}/var/log/glance/{{ item.service_name }}.log
{% else %}
ExecStart={{ glance_bin }}/{{ item.service_name }} {{ program_config_options | default('') }} --log-file=/var/log/glance/{{ item.service_name }}.log
ExecStart={{ glance_bin }}/{{ item.service_name }} {{ item.program_config_options | default('') }} --log-file=/var/log/glance/{{ item.service_name }}.log
{% endif %}
# Give a reasonable amount of time for the server to start up/shut down

View File

@ -0,0 +1,19 @@
[uwsgi]
uid = {{ glance_system_user_name }}
gid = {{ glance_system_group_name }}
virtualenv = /openstack/venvs/glance-{{ glance_venv_tag }}
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
logfile-chmod = 644