Magnum: Support uWSGI for API server

Currently Magnum API server still using eventlet-based HTTP servers,
it is generally considered more performant and flexible to run them
using a generic HTTP server that supports WSGI.

Change-Id: I46c5d72df09e5ce2cb43e2e1b7b1cb316ae2bed6
This commit is contained in:
ricolin 2023-11-02 16:19:47 +08:00
parent 7e3beb1a76
commit 83a1a1e9b4
6 changed files with 34 additions and 4 deletions

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Magnum
name: magnum
version: 0.2.9
version: 0.2.10
home: https://docs.openstack.org/magnum/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Magnum/OpenStack_Project_Magnum_vertical.png
sources:

View File

@ -18,8 +18,7 @@ set -ex
COMMAND="${@:-start}"
function start () {
exec magnum-api \
--config-file /etc/magnum/magnum.conf
exec uwsgi --ini /etc/magnum/magnum-api-uwsgi.ini
}
function stop () {

View File

@ -71,6 +71,15 @@ limitations under the License.
{{- $_ := set .Values.conf.magnum.trust "trustee_domain_admin_password" .Values.endpoints.identity.auth.magnum_stack_user.password -}}
{{- end -}}
{{- if empty .Values.conf.magnum_api_uwsgi.uwsgi.processes -}}
{{- $_ := set .Values.conf.magnum_api_uwsgi.uwsgi "processes" .Values.conf.magnum.api.workers -}}
{{- end -}}
{{- if empty (index .Values.conf.magnum_api_uwsgi.uwsgi "http-socket") -}}
{{- $http_socket_port := tuple "container-infra" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | toString }}
{{- $http_socket := printf "0.0.0.0:%s" $http_socket_port }}
{{- $_ := set .Values.conf.magnum_api_uwsgi.uwsgi "http-socket" $http_socket -}}
{{- end -}}
{{- if and (empty .Values.conf.logging.handler_fluent) (has "fluent" .Values.conf.logging.handlers.keys) -}}
{{- $fluentd_host := tuple "fluentd" "internal" $envAll | include "helm-toolkit.endpoints.hostname_namespaced_endpoint_lookup" }}
{{- $fluentd_port := tuple "fluentd" "internal" "service" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
@ -91,6 +100,7 @@ metadata:
type: Opaque
data:
magnum.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.magnum | b64enc }}
magnum-api-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.magnum_api_uwsgi | b64enc }}
logging.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.logging | b64enc }}
api-paste.ini: {{ include "helm-toolkit.utils.to_ini" .Values.conf.paste | b64enc }}
policy.yaml: {{ toYaml .Values.conf.policy | b64enc }}

View File

@ -75,7 +75,7 @@ spec:
scheme: HTTP
path: /
port: {{ tuple "container-infra" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
initialDelaySeconds: 15
initialDelaySeconds: 5
periodSeconds: 10
volumeMounts:
- name: pod-tmp
@ -92,6 +92,10 @@ spec:
mountPath: /etc/magnum/magnum.conf
subPath: magnum.conf
readOnly: true
- name: magnum-etc
mountPath: /etc/magnum/magnum-api-uwsgi.ini
subPath: magnum-api-uwsgi.ini
readOnly: true
{{- if .Values.conf.magnum.DEFAULT.log_config_append }}
- name: magnum-etc
mountPath: {{ .Values.conf.magnum.DEFAULT.log_config_append }}

View File

@ -157,6 +157,22 @@ conf:
formatter_default:
format: "%(message)s"
datefmt: "%Y-%m-%d %H:%M:%S"
magnum_api_uwsgi:
uwsgi:
add-header: "Connection: close"
buffer-size: 65535
die-on-term: true
enable-threads: true
exit-on-reload: false
hook-master-start: unix_signal:15 gracefully_kill_them_all
lazy-apps: true
log-x-forwarded-for: true
master: true
procname-prefix-spaced: "magnum-api:"
route-user-agent: '^kube-probe.* donotlog:'
thunder-lock: true
worker-reload-mercy: 80
wsgi-file: /var/lib/openstack/bin/magnum-api-wsgi
network:
api:

View File

@ -13,4 +13,5 @@ magnum:
- 0.2.7 Added OCI registry authentication
- 0.2.8 Remove default policy rules
- 0.2.9 Define service_type in keystone_authtoken to support application credentials with access rules
- 0.2.10 Uses uWSGI for API service
...