chore(manila): use uwsgi (#608)

* chore(manila): use uwsgi

* Fix wsgi file name

---------

Co-authored-by: Mohammed Naser <mnaser@vexxhost.com>
diff --git a/charts/manila/templates/bin/_manila-api.sh.tpl b/charts/manila/templates/bin/_manila-api.sh.tpl
index 3521103..dbeecd7 100644
--- a/charts/manila/templates/bin/_manila-api.sh.tpl
+++ b/charts/manila/templates/bin/_manila-api.sh.tpl
@@ -18,8 +18,7 @@
 COMMAND="${@:-start}"
 
 function start () {
-  exec manila-api \
-        --config-file /etc/manila/manila.conf
+  exec uwsgi --ini /etc/manila/manila-api-uwsgi.ini
 }
 
 function stop () {
diff --git a/charts/manila/templates/configmap-etc.yaml b/charts/manila/templates/configmap-etc.yaml
index 15f7fde..b5e7751 100644
--- a/charts/manila/templates/configmap-etc.yaml
+++ b/charts/manila/templates/configmap-etc.yaml
@@ -211,6 +211,15 @@
 {{- $_ := set .Values.conf.manila.glance "memcache_secret_key" $memcache_secret_key -}}
 {{- end -}}
 
+{{- if empty .Values.conf.manila_api_uwsgi.uwsgi.processes -}}
+{{- $_ := set .Values.conf.manila_api_uwsgi.uwsgi "processes" .Values.conf.manila.DEFAULT.osapi_share_workers -}}
+{{- end -}}
+{{- if empty (index .Values.conf.manila_api_uwsgi.uwsgi "http-socket") -}}
+{{- $http_socket_port := tuple "sharev2" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | toString }}
+{{- $http_socket := printf "0.0.0.0:%s" $http_socket_port }}
+{{- $_ := set .Values.conf.manila_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" }}
@@ -232,6 +241,7 @@
 data:
   rally_tests.yaml: {{ toYaml .Values.conf.rally_tests.tests | b64enc }}
   manila.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.manila | b64enc }}
+  manila-api-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.manila_api_uwsgi | b64enc }}
 {{- range $key, $value := $envAll.Values.conf.rootwrap_filters }}
 {{- $filePrefix := replace "_" "-"  $key }}
   {{ printf "%s.filters" $filePrefix }}: {{ $value.content | b64enc }}
diff --git a/charts/manila/templates/deployment-api.yaml b/charts/manila/templates/deployment-api.yaml
index b2169f3..bcc352f 100644
--- a/charts/manila/templates/deployment-api.yaml
+++ b/charts/manila/templates/deployment-api.yaml
@@ -94,6 +94,10 @@
               mountPath: /etc/manila/manila.conf
               subPath: manila.conf
               readOnly: true
+            - name: manila-etc
+              mountPath: /etc/manila/manila-api-uwsgi.ini
+              subPath: manila-api-uwsgi.ini
+              readOnly: true
             {{- if .Values.conf.manila.DEFAULT.log_config_append }}
             - name: manila-etc
               mountPath: {{ .Values.conf.manila.DEFAULT.log_config_append }}
diff --git a/charts/manila/values.yaml b/charts/manila/values.yaml
index f62f14b..e54f214 100644
--- a/charts/manila/values.yaml
+++ b/charts/manila/values.yaml
@@ -802,6 +802,23 @@
           sla:
             failure_rate:
               max: 0
+  manila_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: "manila-api:"
+      route-user-agent: '^kube-probe.* donotlog:'
+      thunder-lock: true
+      worker-reload-mercy: 80
+      wsgi-file: /var/lib/openstack/bin/manila-wsgi
+
 # Names of secrets used by bootstrap and environmental checks
 secrets:
   identity: