From b6e6dad1411a852adf9f7957465bc6854f2d17ce Mon Sep 17 00:00:00 2001 From: ricolin Date: Thu, 2 Nov 2023 14:23:25 +0800 Subject: [PATCH] Senlin: Support uWSGI for API server Currently Senlin 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: I8ec0db12f6002fad8cfde0c873b70279af891994 --- releasenotes/notes/senlin.yaml | 1 + senlin/Chart.yaml | 2 +- senlin/templates/bin/_senlin-api.sh.tpl | 3 +-- senlin/templates/configmap-etc.yaml | 10 ++++++++++ senlin/templates/deployment-api.yaml | 6 +++++- senlin/values.yaml | 16 ++++++++++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/releasenotes/notes/senlin.yaml b/releasenotes/notes/senlin.yaml index 7a0f090367..7952536e50 100644 --- a/releasenotes/notes/senlin.yaml +++ b/releasenotes/notes/senlin.yaml @@ -12,4 +12,5 @@ senlin: - 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 ... diff --git a/senlin/Chart.yaml b/senlin/Chart.yaml index 44d28835ca..f7e4c142fc 100644 --- a/senlin/Chart.yaml +++ b/senlin/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Senlin name: senlin -version: 0.2.9 +version: 0.2.10 home: https://docs.openstack.org/senlin/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Senlin/OpenStack_Project_Senlin_vertical.png sources: diff --git a/senlin/templates/bin/_senlin-api.sh.tpl b/senlin/templates/bin/_senlin-api.sh.tpl index e7de2c1795..88ae1c7281 100644 --- a/senlin/templates/bin/_senlin-api.sh.tpl +++ b/senlin/templates/bin/_senlin-api.sh.tpl @@ -18,8 +18,7 @@ set -ex COMMAND="${@:-start}" function start () { - exec senlin-api \ - --config-file /etc/senlin/senlin.conf + exec uwsgi --ini /etc/senlin/senlin-api-uwsgi.ini } function stop () { diff --git a/senlin/templates/configmap-etc.yaml b/senlin/templates/configmap-etc.yaml index a47a3a4f57..f406d43967 100644 --- a/senlin/templates/configmap-etc.yaml +++ b/senlin/templates/configmap-etc.yaml @@ -81,6 +81,15 @@ limitations under the License. {{- $_ := set .Values.conf.senlin.authentication "service_username" .Values.endpoints.identity.auth.senlin.username -}} {{- end -}} +{{- if empty .Values.conf.senlin_api_uwsgi.uwsgi.processes -}} +{{- $_ := set .Values.conf.senlin_api_uwsgi.uwsgi "processes" .Values.conf.senlin.senlin_api.workers -}} +{{- end -}} +{{- if empty (index .Values.conf.senlin_api_uwsgi.uwsgi "http-socket") -}} +{{- $http_socket_port := tuple "clustering" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | toString }} +{{- $http_socket := printf "0.0.0.0:%s" $http_socket_port }} +{{- $_ := set .Values.conf.senlin_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" }} @@ -102,6 +111,7 @@ type: Opaque data: rally_tests.yaml: {{ toYaml .Values.conf.rally_tests.tests | b64enc }} senlin.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.senlin | b64enc }} + senlin-api-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.senlin_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 }} diff --git a/senlin/templates/deployment-api.yaml b/senlin/templates/deployment-api.yaml index d6577fff8f..6c192eb836 100644 --- a/senlin/templates/deployment-api.yaml +++ b/senlin/templates/deployment-api.yaml @@ -75,7 +75,7 @@ spec: scheme: HTTP path: / port: {{ tuple "clustering" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} - initialDelaySeconds: 15 + initialDelaySeconds: 5 periodSeconds: 10 volumeMounts: - name: pod-tmp @@ -88,6 +88,10 @@ spec: mountPath: /etc/senlin - name: pod-var-cache-senlin mountPath: /var/cache/senlin + - name: senlin-etc + mountPath: /etc/senlin/senlin-api-uwsgi.ini + subPath: senlin-api-uwsgi.ini + readOnly: true - name: senlin-etc mountPath: /etc/senlin/senlin.conf subPath: senlin.conf diff --git a/senlin/values.yaml b/senlin/values.yaml index dee923e4b7..d4f724833d 100644 --- a/senlin/values.yaml +++ b/senlin/values.yaml @@ -204,6 +204,22 @@ conf: formatter_default: format: "%(message)s" datefmt: "%Y-%m-%d %H:%M:%S" + senlin_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: "senlin-api:" + route-user-agent: '^kube-probe.* donotlog:' + thunder-lock: true + worker-reload-mercy: 80 + wsgi-file: /var/lib/openstack/bin/senlin-wsgi-api network: api: