chore(heat): use uwsgi (#606)

* chore(heat): use uwsgi

* Fix wsgi file name and remove cloudwatch
diff --git a/charts/heat/templates/bin/_heat-api.sh.tpl b/charts/heat/templates/bin/_heat-api.sh.tpl
index b756d59..35afabc 100644
--- a/charts/heat/templates/bin/_heat-api.sh.tpl
+++ b/charts/heat/templates/bin/_heat-api.sh.tpl
@@ -49,8 +49,7 @@
   # 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/charts/heat/templates/bin/_heat-cfn.sh.tpl b/charts/heat/templates/bin/_heat-cfn.sh.tpl
index 757b59a..ea94ce8 100644
--- a/charts/heat/templates/bin/_heat-cfn.sh.tpl
+++ b/charts/heat/templates/bin/_heat-cfn.sh.tpl
@@ -50,8 +50,7 @@
   # 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/charts/heat/templates/configmap-etc.yaml b/charts/heat/templates/configmap-etc.yaml
index b49edcd..6de54b2 100644
--- a/charts/heat/templates/configmap-etc.yaml
+++ b/charts/heat/templates/configmap-etc.yaml
@@ -123,6 +123,24 @@
 {{- $_ := 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,9 @@
 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 }}
+  heat-api-cloudwatch-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.heat_api_cloudwatch_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/charts/heat/templates/deployment-api.yaml b/charts/heat/templates/deployment-api.yaml
index 0bed310..ca34656 100644
--- a/charts/heat/templates/deployment-api.yaml
+++ b/charts/heat/templates/deployment-api.yaml
@@ -89,7 +89,7 @@
               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 @@
               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/charts/heat/templates/deployment-cfn.yaml b/charts/heat/templates/deployment-cfn.yaml
index 94ddd06..8401543 100644
--- a/charts/heat/templates/deployment-cfn.yaml
+++ b/charts/heat/templates/deployment-cfn.yaml
@@ -89,7 +89,7 @@
               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
@@ -102,6 +102,10 @@
               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
               readOnly: true
diff --git a/charts/heat/templates/deployment-cloudwatch.yaml b/charts/heat/templates/deployment-cloudwatch.yaml
index f1f7353..4a4189b 100644
--- a/charts/heat/templates/deployment-cloudwatch.yaml
+++ b/charts/heat/templates/deployment-cloudwatch.yaml
@@ -91,6 +91,7 @@
               mountPath: /etc/heat/heat.conf
               subPath: heat.conf
               readOnly: true
+            - name: heat-etc
             {{ if .Values.conf.heat.DEFAULT.log_config_append }}
             - name: heat-etc
               mountPath: {{ .Values.conf.heat.DEFAULT.log_config_append }}
diff --git a/charts/heat/values.yaml b/charts/heat/values.yaml
index ce61e7d..b8cab0d 100644
--- a/charts/heat/values.yaml
+++ b/charts/heat/values.yaml
@@ -475,7 +475,6 @@
     formatter_default:
       format: "%(message)s"
       datefmt: "%Y-%m-%d %H:%M:%S"
-
   rabbitmq:
     # NOTE(rk760n): adding rmq policy to mirror messages from notification queues and set expiration time for the ones
     policies:
@@ -490,6 +489,38 @@
         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/roles/defaults/vars/main.yml b/roles/defaults/vars/main.yml
index a169385..a901160 100644
--- a/roles/defaults/vars/main.yml
+++ b/roles/defaults/vars/main.yml
@@ -43,8 +43,8 @@
   csi_rbd_provisioner: registry.k8s.io/sig-storage/csi-provisioner:v3.1.0
   csi_rbd_resizer: registry.k8s.io/sig-storage/csi-resizer:v1.3.0
   csi_rbd_snapshotter: registry.k8s.io/sig-storage/csi-snapshotter:v4.2.0
-  db_drop: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  db_init: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
+  db_drop: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  db_init: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
   dep_check: quay.io/vexxhost/kubernetes-entrypoint:latest
   designate_api: quay.io/vexxhost/designate@sha256:d65b4d717f81172c63b87bdf85a5db86aedd450f3510b2685ae384c2b114acc8  # image-source: quay.io/vexxhost/designate:zed
   designate_central: quay.io/vexxhost/designate@sha256:d65b4d717f81172c63b87bdf85a5db86aedd450f3510b2685ae384c2b114acc8  # image-source: quay.io/vexxhost/designate:zed
@@ -61,13 +61,13 @@
   grafana_sidecar: quay.io/kiwigrid/k8s-sidecar:1.24.6
   grafana: docker.io/grafana/grafana:10.1.0
   haproxy: docker.io/library/haproxy:2.5
-  heat_api: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  heat_cfn: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  heat_cloudwatch: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  heat_db_sync: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  heat_engine_cleaner: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  heat_engine: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  heat_purge_deleted: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
+  heat_api: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  heat_cfn: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  heat_cloudwatch: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  heat_db_sync: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  heat_engine_cleaner: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  heat_engine: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  heat_purge_deleted: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
   horizon_db_sync: quay.io/vexxhost/horizon@sha256:152d6cec57d241c19ef1e36abc64ff3c1a73e1c877142c067fac0e08957c96f4 # image-source: quay.io/vexxhost/horizon:zed
   horizon: quay.io/vexxhost/horizon@sha256:152d6cec57d241c19ef1e36abc64ff3c1a73e1c877142c067fac0e08957c96f4 # image-source: quay.io/vexxhost/horizon:zed
   ingress_nginx_controller: registry.k8s.io/ingress-nginx/controller:v1.1.1@sha256:0bc88eb15f9e7f84e8e56c14fa5735aaa488b840983f87bd79b1054190e660de
@@ -76,16 +76,16 @@
   keepalived: us-docker.pkg.dev/vexxhost-infra/openstack/keepalived:2.0.19
   keycloak: quay.io/keycloak/keycloak:22.0.1-0
   keystone_api: quay.io/vexxhost/keystone@sha256:4c63257d75c72137454690ad8cef600742e20b07ab31d873b88fa382ce659d17 # image-source: quay.io/vexxhost/keystone:zed
-  keystone_credential_cleanup: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
+  keystone_credential_cleanup: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
   keystone_credential_rotate: quay.io/vexxhost/keystone@sha256:4c63257d75c72137454690ad8cef600742e20b07ab31d873b88fa382ce659d17 # image-source: quay.io/vexxhost/keystone:zed
   keystone_credential_setup: quay.io/vexxhost/keystone@sha256:4c63257d75c72137454690ad8cef600742e20b07ab31d873b88fa382ce659d17 # image-source: quay.io/vexxhost/keystone:zed
   keystone_db_sync: quay.io/vexxhost/keystone@sha256:4c63257d75c72137454690ad8cef600742e20b07ab31d873b88fa382ce659d17 # image-source: quay.io/vexxhost/keystone:zed
-  keystone_domain_manage: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
+  keystone_domain_manage: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
   keystone_fernet_rotate: quay.io/vexxhost/keystone@sha256:4c63257d75c72137454690ad8cef600742e20b07ab31d873b88fa382ce659d17 # image-source: quay.io/vexxhost/keystone:zed
   keystone_fernet_setup: quay.io/vexxhost/keystone@sha256:4c63257d75c72137454690ad8cef600742e20b07ab31d873b88fa382ce659d17 # image-source: quay.io/vexxhost/keystone:zed
-  ks_endpoints: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  ks_service: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
-  ks_user: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
+  ks_endpoints: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  ks_service: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
+  ks_user: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
   kube_apiserver: registry.k8s.io/kube-apiserver:v1.22.17
   kube_controller_manager: registry.k8s.io/kube-controller-manager:v1.22.17
   kube_coredns: registry.k8s.io/coredns/coredns:v1.8.4
@@ -130,7 +130,7 @@
   node_feature_discovery: registry.k8s.io/nfd/node-feature-discovery:v0.11.2
   nova_api: quay.io/vexxhost/nova@sha256:132aec4034dd7508443cd14c7c2b7859a20917b90e17d153a84e2d8f920b5f23 # image-source: quay.io/vexxhost/nova:zed
   nova_archive_deleted_rows: quay.io/vexxhost/nova@sha256:132aec4034dd7508443cd14c7c2b7859a20917b90e17d153a84e2d8f920b5f23 # image-source: quay.io/vexxhost/nova:zed
-  nova_cell_setup_init: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
+  nova_cell_setup_init: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
   nova_cell_setup: quay.io/vexxhost/nova@sha256:132aec4034dd7508443cd14c7c2b7859a20917b90e17d153a84e2d8f920b5f23 # image-source: quay.io/vexxhost/nova:zed
   nova_compute_ironic: quay.io/openstack.kolla/nova-compute-ironic:zed-ubuntu-jammy
   nova_compute_ssh: quay.io/vexxhost/nova-ssh:latest
@@ -147,7 +147,7 @@
   nova_spiceproxy: quay.io/vexxhost/nova@sha256:132aec4034dd7508443cd14c7c2b7859a20917b90e17d153a84e2d8f920b5f23 # image-source: quay.io/vexxhost/nova:zed
   octavia_api: quay.io/vexxhost/octavia@sha256:9065365ed1d731e5130dcf7d600bc8dc8ffa158093c53dd151eddfe49a29a5ee # image-source: quay.io/vexxhost/octavia:zed
   octavia_db_sync: quay.io/vexxhost/octavia@sha256:9065365ed1d731e5130dcf7d600bc8dc8ffa158093c53dd151eddfe49a29a5ee # image-source: quay.io/vexxhost/octavia:zed
-  octavia_health_manager_init: quay.io/vexxhost/heat@sha256:755225f9a63c0968f1ceeda3a2f06c66dd8d247ff00308f549e66496aa8f59d0 # image-source: quay.io/vexxhost/heat:zed
+  octavia_health_manager_init: quay.io/vexxhost/heat@sha256:2413e1d669a899685d0cc89c3333222ad004c567be0d5ca605dcc6a59c12af64 # image-source: quay.io/vexxhost/heat:zed
   octavia_health_manager: quay.io/vexxhost/octavia@sha256:9065365ed1d731e5130dcf7d600bc8dc8ffa158093c53dd151eddfe49a29a5ee # image-source: quay.io/vexxhost/octavia:zed
   octavia_housekeeping: quay.io/vexxhost/octavia@sha256:9065365ed1d731e5130dcf7d600bc8dc8ffa158093c53dd151eddfe49a29a5ee # image-source: quay.io/vexxhost/octavia:zed
   octavia_worker: quay.io/vexxhost/octavia@sha256:9065365ed1d731e5130dcf7d600bc8dc8ffa158093c53dd151eddfe49a29a5ee # image-source: quay.io/vexxhost/octavia:zed