chore(selin): use wsgi (#624)

Co-authored-by: Mohammed Naser <mnaser@vexxhost.com>
diff --git a/charts/senlin/templates/bin/_senlin-api.sh.tpl b/charts/senlin/templates/bin/_senlin-api.sh.tpl
index e7de2c1..88ae1c7 100644
--- a/charts/senlin/templates/bin/_senlin-api.sh.tpl
+++ b/charts/senlin/templates/bin/_senlin-api.sh.tpl
@@ -18,8 +18,7 @@
 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/charts/senlin/templates/configmap-etc.yaml b/charts/senlin/templates/configmap-etc.yaml
index a47a3a4..f406d43 100644
--- a/charts/senlin/templates/configmap-etc.yaml
+++ b/charts/senlin/templates/configmap-etc.yaml
@@ -81,6 +81,15 @@
 {{- $_ := 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 @@
 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/charts/senlin/templates/deployment-api.yaml b/charts/senlin/templates/deployment-api.yaml
index d6577ff..6c192eb 100644
--- a/charts/senlin/templates/deployment-api.yaml
+++ b/charts/senlin/templates/deployment-api.yaml
@@ -75,7 +75,7 @@
               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
@@ -89,6 +89,10 @@
             - 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
               readOnly: true
diff --git a/charts/senlin/values.yaml b/charts/senlin/values.yaml
index dee923e..d4f7248 100644
--- a/charts/senlin/values.yaml
+++ b/charts/senlin/values.yaml
@@ -204,6 +204,22 @@
     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:
diff --git a/roles/defaults/vars/main.yml b/roles/defaults/vars/main.yml
index 9dedecc..e004e72 100644
--- a/roles/defaults/vars/main.yml
+++ b/roles/defaults/vars/main.yml
@@ -179,12 +179,12 @@
   rabbitmq_server: docker.io/library/rabbitmq:3.10.2-management
   rabbitmq_topology_operator: docker.io/rabbitmqoperator/messaging-topology-operator:1.6.0
   rook_ceph: docker.io/rook/ceph:v1.10.10
-  senlin_api: quay.io/vexxhost/senlin@sha256:66e064a6337fd86f7936d2724ae45136ee8429b486e236fb34e03874034fed70 # image-source: quay.io/vexxhost/senlin:zed
-  senlin_conductor: quay.io/vexxhost/senlin@sha256:66e064a6337fd86f7936d2724ae45136ee8429b486e236fb34e03874034fed70 # image-source: quay.io/vexxhost/senlin:zed
-  senlin_db_sync: quay.io/vexxhost/senlin@sha256:66e064a6337fd86f7936d2724ae45136ee8429b486e236fb34e03874034fed70 # image-source: quay.io/vexxhost/senlin:zed
-  senlin_engine_cleaner: quay.io/vexxhost/senlin@sha256:66e064a6337fd86f7936d2724ae45136ee8429b486e236fb34e03874034fed70 # image-source: quay.io/vexxhost/senlin:zed
-  senlin_engine: quay.io/vexxhost/senlin@sha256:66e064a6337fd86f7936d2724ae45136ee8429b486e236fb34e03874034fed70 # image-source: quay.io/vexxhost/senlin:zed
-  senlin_health_manager: quay.io/vexxhost/senlin@sha256:66e064a6337fd86f7936d2724ae45136ee8429b486e236fb34e03874034fed70 # image-source: quay.io/vexxhost/senlin:zed
+  senlin_api: quay.io/vexxhost/senlin@sha256:5cb3108dfdeb02a8d910aa2666d8865c772774e431ceaf69391959d87e2b0674 # image-source: quay.io/vexxhost/senlin:zed
+  senlin_conductor: quay.io/vexxhost/senlin@sha256:5cb3108dfdeb02a8d910aa2666d8865c772774e431ceaf69391959d87e2b0674 # image-source: quay.io/vexxhost/senlin:zed
+  senlin_db_sync: quay.io/vexxhost/senlin@sha256:5cb3108dfdeb02a8d910aa2666d8865c772774e431ceaf69391959d87e2b0674 # image-source: quay.io/vexxhost/senlin:zed
+  senlin_engine_cleaner: quay.io/vexxhost/senlin@sha256:5cb3108dfdeb02a8d910aa2666d8865c772774e431ceaf69391959d87e2b0674 # image-source: quay.io/vexxhost/senlin:zed
+  senlin_engine: quay.io/vexxhost/senlin@sha256:5cb3108dfdeb02a8d910aa2666d8865c772774e431ceaf69391959d87e2b0674 # image-source: quay.io/vexxhost/senlin:zed
+  senlin_health_manager: quay.io/vexxhost/senlin@sha256:5cb3108dfdeb02a8d910aa2666d8865c772774e431ceaf69391959d87e2b0674 # image-source: quay.io/vexxhost/senlin:zed
   skopeo: quay.io/skopeo/stable:latest
   tempest_run_tests: us-docker.pkg.dev/vexxhost-infra/openstack/tempest:30.1.0-4
   vector: docker.io/timberio/vector:0.27.0-debian