chore(cinder): use uwsgi (#603)

* chore(cinder): use uwsgi

* update image tags
diff --git a/charts/cinder/templates/bin/_cinder-api.sh.tpl b/charts/cinder/templates/bin/_cinder-api.sh.tpl
index 3b64745..b9e5557 100644
--- a/charts/cinder/templates/bin/_cinder-api.sh.tpl
+++ b/charts/cinder/templates/bin/_cinder-api.sh.tpl
@@ -48,8 +48,7 @@
   # Starts Apache2
   exec {{ .Values.conf.software.apache2.binary }} {{ .Values.conf.software.apache2.start_parameters }}
 {{- else }}
-  exec cinder-api \
-        --config-file /etc/cinder/cinder.conf
+    exec uwsgi --ini /etc/cinder/cinder-api-uwsgi.ini
 {{- end }}
 }
 
diff --git a/charts/cinder/templates/configmap-etc.yaml b/charts/cinder/templates/configmap-etc.yaml
index 5010ab9..1a20ea8 100644
--- a/charts/cinder/templates/configmap-etc.yaml
+++ b/charts/cinder/templates/configmap-etc.yaml
@@ -144,6 +144,15 @@
 {{- end -}}
 {{- end -}}
 
+{{- if empty .Values.conf.cinder_api_uwsgi.uwsgi.processes -}}
+{{- $_ := set .Values.conf.cinder_api_uwsgi.uwsgi "processes" .Values.conf.cinder.DEFAULT.osapi_volume_workers -}}
+{{- end -}}
+{{- if empty (index .Values.conf.cinder_api_uwsgi.uwsgi "http-socket") -}}
+{{- $http_socket_port := tuple "volume" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | toString }}
+{{- $http_socket := printf "0.0.0.0:%s" $http_socket_port }}
+{{- $_ := set .Values.conf.cinder_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" }}
@@ -168,6 +177,7 @@
   logging.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.logging | b64enc }}
   backends.conf: {{ include "helm-toolkit.utils.to_ini" .Values.conf.backends | b64enc }}
   api-paste.ini: {{ include "helm-toolkit.utils.to_ini" .Values.conf.paste | b64enc }}
+  cinder-api-uwsgi.ini: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.cinder_api_uwsgi | b64enc }}
   policy.yaml: {{ toYaml .Values.conf.policy | b64enc }}
 {{- if .Values.manifests.certificates }}
 {{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.mpm_event "key" "mpm_event.conf" "format" "Secret" ) | indent 2 }}
diff --git a/charts/cinder/templates/deployment-api.yaml b/charts/cinder/templates/deployment-api.yaml
index 8ef5754..feab3ef 100644
--- a/charts/cinder/templates/deployment-api.yaml
+++ b/charts/cinder/templates/deployment-api.yaml
@@ -104,7 +104,7 @@
               scheme: {{ tuple "volume" "service" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_scheme_lookup" | upper }}
               path: /
               port: {{ tuple "volume" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
-            initialDelaySeconds: 30
+            initialDelaySeconds: 5
             failureThreshold: 3
             periodSeconds: 10
             successThreshold: 1
@@ -119,6 +119,10 @@
               subPath: cinder-api.sh
               readOnly: true
             - name: cinder-etc
+              mountPath: /etc/cinder/cinder-api-uwsgi.ini
+              subPath: cinder-api-uwsgi.ini
+              readOnly: true
+            - name: cinder-etc
               mountPath: /etc/cinder/cinder.conf
               subPath: cinder.conf
               readOnly: true
diff --git a/charts/cinder/values.yaml b/charts/cinder/values.yaml
index 28c2dc6..0c50ec6 100644
--- a/charts/cinder/values.yaml
+++ b/charts/cinder/values.yaml
@@ -1011,6 +1011,23 @@
       - volume_type
     volume_type: []
   enable_iscsi: false
+  cinder_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: "cinder-api:"
+      route-user-agent: '^kube-probe.* donotlog:'
+      thunder-lock: true
+      worker-reload-mercy: 80
+      wsgi-file: /var/lib/openstack/bin/cinder-wsgi
+
 backup:
   external_ceph_rbd:
     enabled: false
diff --git a/roles/defaults/vars/main.yml b/roles/defaults/vars/main.yml
index 9e139a6..93be37c 100644
--- a/roles/defaults/vars/main.yml
+++ b/roles/defaults/vars/main.yml
@@ -25,14 +25,14 @@
   cert_manager_webhook: quay.io/jetstack/cert-manager-webhook:v1.7.1
   cilium_node: quay.io/cilium/cilium:v1.13.3@sha256:77176464a1e11ea7e89e984ac7db365e7af39851507e94f137dcf56c87746314
   cilium_operator: quay.io/cilium/operator-generic:v1.13.3@sha256:fa7003cbfdf8358cb71786afebc711b26e5e44a2ed99bd4944930bba915b8910
-  cinder_api: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
-  cinder_backup_storage_init: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
-  cinder_backup: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
-  cinder_db_sync: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
-  cinder_scheduler: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
-  cinder_storage_init: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
-  cinder_volume_usage_audit: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
-  cinder_volume: quay.io/vexxhost/cinder@sha256:875bc983a9c2a2d1fb6a952d147f2474a169dc77eb9dff4741f3a185c28753fb # image-source: quay.io/vexxhost/cinder:zed
+  cinder_api: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
+  cinder_backup_storage_init: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
+  cinder_backup: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
+  cinder_db_sync: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
+  cinder_scheduler: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
+  cinder_storage_init: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
+  cinder_volume_usage_audit: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
+  cinder_volume: quay.io/vexxhost/cinder@sha256:39f8d16322fc84a8e9a3084cb35e85450451a33583e121e8a73e38373eb6d582 # image-source: quay.io/vexxhost/cinder:zed
   cluster_api_controller: registry.k8s.io/cluster-api/cluster-api-controller:v1.4.4
   cluster_api_kubeadm_bootstrap_controller: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.4.4
   cluster_api_kubeadm_control_plane_controller: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.4.4