From f44f1ba7f1b36a7aaed159b28143ac1fb78c5d8f Mon Sep 17 00:00:00 2001
From: Pete Birley <pete@port.direct>
Date: Wed, 31 May 2017 09:47:33 -0500
Subject: [PATCH] Consistency: Move Mistral container start commands to scripts

This PS moves the container start commands to scripts. This brings
the service into alignment with others in OpenStack-Helm, and enables
easier debugging and modifcation of the launch commands for services.

Change-Id: I1d063eaf1c15d94bc14988affbcedb627aa8c212
---
 mistral/templates/bin/_mistral-api.sh.tpl     | 20 +++++++++++++++++++
 mistral/templates/bin/_mistral-engine.sh.tpl  | 20 +++++++++++++++++++
 .../bin/_mistral-event-engine.sh.tpl          | 20 +++++++++++++++++++
 .../templates/bin/_mistral-executor.sh.tpl    | 20 +++++++++++++++++++
 mistral/templates/configmap-bin.yaml          |  9 ++++++++-
 mistral/templates/deployment-api.yaml         | 14 ++++++++-----
 mistral/templates/deployment-executor.yaml    | 14 ++++++++-----
 mistral/templates/statefulset-engine.yaml     | 14 ++++++++-----
 .../templates/statefulset-event-engine.yaml   | 14 ++++++++-----
 9 files changed, 124 insertions(+), 21 deletions(-)
 create mode 100644 mistral/templates/bin/_mistral-api.sh.tpl
 create mode 100644 mistral/templates/bin/_mistral-engine.sh.tpl
 create mode 100644 mistral/templates/bin/_mistral-event-engine.sh.tpl
 create mode 100644 mistral/templates/bin/_mistral-executor.sh.tpl

diff --git a/mistral/templates/bin/_mistral-api.sh.tpl b/mistral/templates/bin/_mistral-api.sh.tpl
new file mode 100644
index 0000000000..8c2e4bbcf0
--- /dev/null
+++ b/mistral/templates/bin/_mistral-api.sh.tpl
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Copyright 2017 The Openstack-Helm Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -x
+exec mistral-server \
+      --server api \
+      --config-file /etc/mistral/mistral.conf
diff --git a/mistral/templates/bin/_mistral-engine.sh.tpl b/mistral/templates/bin/_mistral-engine.sh.tpl
new file mode 100644
index 0000000000..ac74543ee7
--- /dev/null
+++ b/mistral/templates/bin/_mistral-engine.sh.tpl
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Copyright 2017 The Openstack-Helm Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -x
+exec mistral-server \
+      --server engine \
+      --config-file /etc/mistral/mistral.conf
diff --git a/mistral/templates/bin/_mistral-event-engine.sh.tpl b/mistral/templates/bin/_mistral-event-engine.sh.tpl
new file mode 100644
index 0000000000..83faced05c
--- /dev/null
+++ b/mistral/templates/bin/_mistral-event-engine.sh.tpl
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Copyright 2017 The Openstack-Helm Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -x
+exec mistral-server \
+      --server event-engine \
+      --config-file /etc/mistral/mistral.conf
diff --git a/mistral/templates/bin/_mistral-executor.sh.tpl b/mistral/templates/bin/_mistral-executor.sh.tpl
new file mode 100644
index 0000000000..5b16b754e3
--- /dev/null
+++ b/mistral/templates/bin/_mistral-executor.sh.tpl
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Copyright 2017 The Openstack-Helm Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -x
+exec mistral-server \
+      --server executor \
+      --config-file /etc/mistral/mistral.conf
diff --git a/mistral/templates/configmap-bin.yaml b/mistral/templates/configmap-bin.yaml
index 30e5b8e887..658fcad181 100644
--- a/mistral/templates/configmap-bin.yaml
+++ b/mistral/templates/configmap-bin.yaml
@@ -29,4 +29,11 @@ data:
 {{- include "helm-toolkit.scripts.keystone_user" . | indent 4 }}
   ks-domain-user.sh: |+
 {{- include "helm-toolkit.scripts.keystone_domain_user" . | indent 4 }}
-
+  mistral-api.sh: |
+{{ tuple "bin/_mistral-api.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
+  mistral-engine.sh: |
+{{ tuple "bin/_mistral-engine.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
+  mistral-event-engine.sh: |
+{{ tuple "bin/_mistral-event-engine.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
+  mistral-executor.sh: |
+{{ tuple "bin/_mistral-executor.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
diff --git a/mistral/templates/deployment-api.yaml b/mistral/templates/deployment-api.yaml
index ea6ef90930..fae258b6ce 100644
--- a/mistral/templates/deployment-api.yaml
+++ b/mistral/templates/deployment-api.yaml
@@ -57,11 +57,8 @@ spec:
               memory: {{ .Values.resources.api.requests.memory | quote }}
           {{- end }}
           command:
-          - mistral-server
-          - --server
-          - api
-          - --config-file
-          - /etc/mistral/mistral.conf
+            - bash
+            - /tmp/mistral-api.sh
           ports:
             - name: {{ .Values.network.api.name }}
               containerPort: {{ .Values.conf.mistral.api.mistral.config.port }}
@@ -71,6 +68,10 @@ spec:
           volumeMounts:
             - name: pod-etc-mistral
               mountPath: /etc/mistral
+            - name: mistral-bin
+              mountPath: /tmp/mistral-api.sh
+              subPath: mistral-api.sh
+              readOnly: true
             - name: mistral-etc
               mountPath: /etc/mistral/mistral.conf
               subPath: mistral.conf
@@ -83,6 +84,9 @@ spec:
       volumes:
         - name: pod-etc-mistral
           emptyDir: {}
+        - name: mistral-bin
+          configMap:
+            name: mistral-bin
         - name: mistral-etc
           configMap:
             name: mistral-etc
diff --git a/mistral/templates/deployment-executor.yaml b/mistral/templates/deployment-executor.yaml
index af4fdae8e2..b0df3b2ef5 100644
--- a/mistral/templates/deployment-executor.yaml
+++ b/mistral/templates/deployment-executor.yaml
@@ -57,14 +57,15 @@ spec:
               memory: {{ .Values.resources.executor.requests.memory | quote }}
           {{- end }}
           command:
-          - mistral-server
-          - --server
-          - executor
-          - --config-file
-          - /etc/mistral/mistral.conf
+            - bash
+            - /tmp/mistral-executor.sh
           volumeMounts:
             - name: pod-etc-mistral
               mountPath: /etc/mistral
+            - name: mistral-bin
+              mountPath: /tmp/mistral-executor.sh
+              subPath: mistral-executor.sh
+              readOnly: true
             - name: mistral-etc
               mountPath: /etc/mistral/mistral.conf
               subPath: mistral.conf
@@ -73,6 +74,9 @@ spec:
       volumes:
         - name: pod-etc-mistral
           emptyDir: {}
+        - name: mistral-bin
+          configMap:
+            name: mistral-bin
         - name: mistral-etc
           configMap:
             name: mistral-etc
diff --git a/mistral/templates/statefulset-engine.yaml b/mistral/templates/statefulset-engine.yaml
index 4fb493bfe4..82520709d2 100644
--- a/mistral/templates/statefulset-engine.yaml
+++ b/mistral/templates/statefulset-engine.yaml
@@ -48,14 +48,15 @@ spec:
               memory: {{ .Values.resources.engine.requests.memory | quote }}
           {{- end }}
           command:
-          - mistral-server
-          - --server
-          - engine
-          - --config-file
-          - /etc/mistral/mistral.conf
+            - bash
+            - /tmp/mistral-engine.sh
           volumeMounts:
             - name: pod-etc-mistral
               mountPath: /etc/mistral
+            - name: mistral-bin
+              mountPath: /tmp/mistral-engine.sh
+              subPath: mistral-engine.sh
+              readOnly: true
             - name: mistral-etc
               mountPath: /etc/mistral/mistral.conf
               subPath: mistral.conf
@@ -64,6 +65,9 @@ spec:
       volumes:
         - name: pod-etc-mistral
           emptyDir: {}
+        - name: mistral-bin
+          configMap:
+            name: mistral-bin
         - name: mistral-etc
           configMap:
             name: mistral-etc
diff --git a/mistral/templates/statefulset-event-engine.yaml b/mistral/templates/statefulset-event-engine.yaml
index 5d9a85f846..a67d93bda1 100644
--- a/mistral/templates/statefulset-event-engine.yaml
+++ b/mistral/templates/statefulset-event-engine.yaml
@@ -48,14 +48,15 @@ spec:
               memory: {{ .Values.resources.event_engine.requests.memory | quote }}
           {{- end }}
           command:
-          - mistral-server
-          - --server
-          - event-engine
-          - --config-file
-          - /etc/mistral/mistral.conf
+            - bash
+            - /tmp/mistral-event-engine.sh
           volumeMounts:
             - name: pod-etc-mistral
               mountPath: /etc/mistral
+            - name: mistral-bin
+              mountPath: /tmp/mistral-event-engine.sh
+              subPath: mistral-event-engine.sh
+              readOnly: true
             - name: mistral-etc
               mountPath: /etc/mistral/mistral.conf
               subPath: mistral.conf
@@ -64,6 +65,9 @@ spec:
       volumes:
         - name: pod-etc-mistral
           emptyDir: {}
+        - name: mistral-bin
+          configMap:
+            name: mistral-bin
         - name: mistral-etc
           configMap:
             name: mistral-etc