From 42d6c2321de5e14b61ed47f6eed09668e98e20e4 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Fri, 17 May 2019 14:51:15 +0200 Subject: [PATCH] mysql: set hostpath for mysql-data There is currently an issue with deploying single pod mysql clusters in which restarting or killing the pod will result in a crashloopbackoff. The mysql data is indeed lost and the start script (thinking the cluster was alive before due to the grastate configmap) tries to restore the cluster instead of bootstrapping it. Due to this, if the mysql pod is killed or restarted in the CI, we will lose all the mysql data, will not recover, and this results in a broken environment. When volume.use_local_path_for_single_pod.enabled value is set to true, which we will apply on single node/single pod testing, this patch will deploy a local volume for mysql at the location specified under volume.use_local_path_for_single_pod.host_path The data will be kept intact in case there is a pod restart, as it can read the data again, and recover itself. When it is false, which is the default for non-CI, nothing changes, and an empty dir is used. This data WILL be lost upon restart, so it is advised to use volumes instead for production purposes, by setting Values.volume.enabled to true. task: 28729 Change-Id: I6ec0bd1087eb06b92ced7dc56ff5b6a156aad433 --- mariadb/templates/statefulset.yaml | 4 ++++ mariadb/values.yaml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/mariadb/templates/statefulset.yaml b/mariadb/templates/statefulset.yaml index 8beab96d0..1ab707935 100644 --- a/mariadb/templates/statefulset.yaml +++ b/mariadb/templates/statefulset.yaml @@ -239,8 +239,12 @@ spec: defaultMode: 0444 {{- if not .Values.volume.enabled }} - name: mysql-data + {{- if .Values.volume.use_local_path_for_single_pod_cluster.enabled }} + hostPath: {{ .Values.volume.use_local_path_for_single_pod_cluster.host_path }} + {{- else }} emptyDir: {} {{- end }} + {{- end }} {{- if .Values.volume.enabled }} volumeClaimTemplates: - metadata: diff --git a/mariadb/values.yaml b/mariadb/values.yaml index 4a2c44bdf..48786222c 100644 --- a/mariadb/values.yaml +++ b/mariadb/values.yaml @@ -229,6 +229,11 @@ dependencies: service: oslo_db volume: + # this value is used for single pod deployments of mariadb to prevent losing all data + # if the pod is restarted + use_local_path_for_single_pod: + enabled: false + host_path: "/tmp/mysql-data" chown_on_start: true enabled: true class_name: general