From f6ce5ad406731be73c8a4410098c55d0b71e688c Mon Sep 17 00:00:00 2001 From: ricolin Date: Thu, 2 Nov 2023 16:36:51 +0800 Subject: [PATCH] Heat: Support uWSGI for API server Currently Heat 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: I5c5ac8ca3111cf1149c3fb083ea56e3ed2ce460c --- heat/Chart.yaml | 2 +- heat/templates/bin/_heat-api.sh.tpl | 3 +-- heat/templates/bin/_heat-cfn.sh.tpl | 3 +-- heat/templates/configmap-etc.yaml | 20 ++++++++++++++++++ heat/templates/deployment-api.yaml | 6 +++++- heat/templates/deployment-cfn.yaml | 6 +++++- heat/values.yaml | 32 +++++++++++++++++++++++++++++ releasenotes/notes/heat.yaml | 1 + 8 files changed, 66 insertions(+), 7 deletions(-) diff --git a/heat/Chart.yaml b/heat/Chart.yaml index 248aa3cc61..8e7e67bff0 100644 --- a/heat/Chart.yaml +++ b/heat/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Heat name: heat -version: 0.3.8 +version: 0.3.9 home: https://docs.openstack.org/heat/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Heat/OpenStack_Project_Heat_vertical.png sources: diff --git a/heat/templates/bin/_heat-api.sh.tpl b/heat/templates/bin/_heat-api.sh.tpl index b756d59e1f..35afabcbf3 100644 --- a/heat/templates/bin/_heat-api.sh.tpl +++ b/heat/templates/bin/_heat-api.sh.tpl @@ -49,8 +49,7 @@ function start () { # Starts Apache2 exec {{ .Values.conf.software.apache2.binary }} {{ .Values.conf.software.apache2.start_parameters }} {{- else }} - exec heat-api \ - --config-file /etc/heat/heat.conf + exec uwsgi --ini /etc/heat/heat-api-uwsgi.ini {{- end }} } diff --git a/heat/templates/bin/_heat-cfn.sh.tpl b/heat/templates/bin/_heat-cfn.sh.tpl index 757b59afc9..ea94ce8a70 100644 --- a/heat/templates/bin/_heat-cfn.sh.tpl +++ b/heat/templates/bin/_heat-cfn.sh.tpl @@ -50,8 +50,7 @@ function start () { # Starts Apache2 exec {{ .Values.conf.software.apache2.binary }} {{ .Values.conf.software.apache2.start_parameters }} {{- else }} - exec heat-api-cfn \ - --config-file /etc/heat/heat.conf + exec uwsgi --ini /etc/heat/heat-api-cfn-uwsgi.ini {{- end }} } diff --git a/heat/templates/configmap-etc.yaml b/heat/templates/configmap-etc.yaml index b49edcd14c..a14d087ace 100644 --- a/heat/templates/configmap-etc.yaml +++ b/heat/templates/configmap-etc.yaml @@ -123,6 +123,24 @@ limitations under the License. {{- $_ := tuple "cloudformation" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | set .Values.conf.heat.heat_api_cfn "bind_port" -}} {{- end -}} +{{- if empty .Values.conf.heat_api_uwsgi.uwsgi.processes -}} +{{- $_ := set .Values.conf.heat_api_uwsgi.uwsgi "processes" .Values.conf.heat.heat_api.workers -}} +{{- end -}} +{{- if empty (index .Values.conf.heat_api_uwsgi.uwsgi "http-socket") -}} +{{- $http_socket_port := tuple "orchestration" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | toString }} +{{- $http_socket := printf "0.0.0.0:%s" $http_socket_port }} +{{- $_ := set .Values.conf.heat_api_uwsgi.uwsgi "http-socket" $http_socket -}} +{{- end -}} + +{{- if empty .Values.conf.heat_api_cfn_uwsgi.uwsgi.processes -}} +{{- $_ := set .Values.conf.heat_api_cfn_uwsgi.uwsgi "processes" .Values.conf.heat.heat_api_cfn.workers -}} +{{- end -}} +{{- if empty (index .Values.conf.heat_api_cfn_uwsgi.uwsgi "http-socket") -}} +{{- $http_socket_port := tuple "cloudformation" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | toString }} +{{- $http_socket := printf "0.0.0.0:%s" $http_socket_port }} +{{- $_ := set .Values.conf.heat_api_cfn_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" }} @@ -144,6 +162,8 @@ type: Opaque data: rally_tests.yaml: {{ toYaml .Values.conf.rally_tests.tests | b64enc }} heat.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.heat | b64enc }} + heat-api-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.heat_api_uwsgi | b64enc }} + heat-api-cfn-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.heat_api_cfn_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/heat/templates/deployment-api.yaml b/heat/templates/deployment-api.yaml index 0bed310b59..ca34656391 100644 --- a/heat/templates/deployment-api.yaml +++ b/heat/templates/deployment-api.yaml @@ -89,7 +89,7 @@ spec: scheme: {{ tuple "orchestration" "service" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_scheme_lookup" | upper }} path: / port: {{ tuple "orchestration" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} - initialDelaySeconds: 30 + initialDelaySeconds: 10 volumeMounts: - name: pod-tmp mountPath: /tmp @@ -105,6 +105,10 @@ spec: mountPath: /etc/heat/heat.conf subPath: heat.conf readOnly: true + - name: heat-etc + mountPath: /etc/heat/heat-api-uwsgi.ini + subPath: heat-api-uwsgi.ini + readOnly: true {{ if .Values.conf.heat.DEFAULT.log_config_append }} - name: heat-etc mountPath: {{ .Values.conf.heat.DEFAULT.log_config_append }} diff --git a/heat/templates/deployment-cfn.yaml b/heat/templates/deployment-cfn.yaml index 94ddd0674e..84015438d8 100644 --- a/heat/templates/deployment-cfn.yaml +++ b/heat/templates/deployment-cfn.yaml @@ -89,7 +89,7 @@ spec: scheme: {{ tuple "cloudformation" "service" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_scheme_lookup" | upper }} path: / port: {{ tuple "cloudformation" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} - initialDelaySeconds: 30 + initialDelaySeconds: 10 volumeMounts: - name: pod-tmp mountPath: /tmp @@ -101,6 +101,10 @@ spec: mountPath: /tmp/heat-cfn.sh subPath: heat-cfn.sh readOnly: true + - name: heat-etc + mountPath: /etc/heat/heat-api-cfn-uwsgi.ini + subPath: heat-api-cfn-uwsgi.ini + readOnly: true - name: heat-etc mountPath: /etc/heat/heat.conf subPath: heat.conf diff --git a/heat/values.yaml b/heat/values.yaml index ce61e7dda5..c9b8cdd952 100644 --- a/heat/values.yaml +++ b/heat/values.yaml @@ -490,6 +490,38 @@ conf: priority: 0 apply-to: all pattern: '^(?!(amq\.|reply_)).*' + heat_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: "heat-api:" + route-user-agent: '^kube-probe.* donotlog:' + thunder-lock: true + worker-reload-mercy: 80 + wsgi-file: /var/lib/openstack/bin/heat-wsgi-api + heat_api_cfn_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: "heat-api-cfn:" + route-user-agent: '^kube-probe.* donotlog:' + thunder-lock: true + worker-reload-mercy: 80 + wsgi-file: /var/lib/openstack/bin/heat-wsgi-api-cfn network: api: diff --git a/releasenotes/notes/heat.yaml b/releasenotes/notes/heat.yaml index 5dec1d1de1..0197786b35 100644 --- a/releasenotes/notes/heat.yaml +++ b/releasenotes/notes/heat.yaml @@ -34,4 +34,5 @@ heat: - 0.3.6 Add Ubuntu Jammy overrides - 0.3.7 Add 2023.2 Ubuntu Jammy overrides - 0.3.8 Fixed annotation indentation for jobs + - 0.3.9 Uses uWSGI for API services ...