From 80a14e940e54bb31b2ff384a1b36a7eea0bf970f Mon Sep 17 00:00:00 2001 From: Daniel Badea Date: Thu, 20 Jun 2019 14:02:32 +0000 Subject: [PATCH] Cinder replace is_ceph_volume_configured In preparation for supporting multiple Ceph backends replace is_ceph_volume_configured with has_ceph_backend. has_ceph_backend returns true when at least one backend is using RBDDriver. Change-Id: Iaa67061b05a9d355228ad7d3f5ee0f4f04dbdc66 Signed-off-by: Daniel Badea . --- cinder/templates/deployment-backup.yaml | 8 ++++---- cinder/templates/deployment-volume.yaml | 6 +++--- cinder/templates/job-clean.yaml | 4 ++-- cinder/templates/job-storage-init.yaml | 8 ++++---- ...lume_configured.tpl => _has_ceph_backend.tpl} | 16 ++++++++-------- 5 files changed, 21 insertions(+), 21 deletions(-) mode change 100644 => 100755 cinder/templates/deployment-backup.yaml mode change 100644 => 100755 cinder/templates/deployment-volume.yaml mode change 100644 => 100755 cinder/templates/job-clean.yaml mode change 100644 => 100755 cinder/templates/job-storage-init.yaml rename cinder/templates/utils/{_is_ceph_volume_configured.tpl => _has_ceph_backend.tpl} (64%) diff --git a/cinder/templates/deployment-backup.yaml b/cinder/templates/deployment-backup.yaml old mode 100644 new mode 100755 index ed98fdc49a..835c2597fb --- a/cinder/templates/deployment-backup.yaml +++ b/cinder/templates/deployment-backup.yaml @@ -78,7 +78,7 @@ spec: subPath: key readOnly: true {{ end }} - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: ceph-keyring-placement {{ tuple $envAll "cinder_backup" | include "helm-toolkit.snippets.image" | indent 10 }} securityContext: @@ -162,7 +162,7 @@ spec: subPath: {{ base .Values.conf.cinder.DEFAULT.log_config_append }} readOnly: true {{- end }} - {{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.is_ceph_volume_configured" $envAll) }} + {{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.has_ceph_backend" $envAll) }} - name: etcceph mountPath: /etc/ceph {{- if not .Values.backup.external_ceph_rbd.enabled }} @@ -227,7 +227,7 @@ spec: configMap: name: cinder-bin defaultMode: 0555 - {{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.is_ceph_volume_configured" $envAll) }} + {{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.has_ceph_backend" $envAll) }} - name: etcceph emptyDir: {} - name: ceph-etc @@ -240,7 +240,7 @@ spec: secret: secretName: {{ .Values.secrets.rbd.backup | quote }} {{ end }} - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: ceph-keyring secret: secretName: {{ .Values.secrets.rbd.volume | quote }} diff --git a/cinder/templates/deployment-volume.yaml b/cinder/templates/deployment-volume.yaml old mode 100644 new mode 100755 index fcabd0fc13..45298d59a3 --- a/cinder/templates/deployment-volume.yaml +++ b/cinder/templates/deployment-volume.yaml @@ -54,7 +54,7 @@ spec: {{ .Values.labels.volume.node_selector_key }}: {{ .Values.labels.volume.node_selector_value }} initContainers: {{ tuple $envAll "volume" $mounts_cinder_volume_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: ceph-keyring-placement {{ tuple $envAll "cinder_volume" | include "helm-toolkit.snippets.image" | indent 10 }} securityContext: @@ -153,7 +153,7 @@ spec: mountPath: /etc/cinder/conf/backends.conf subPath: backends.conf readOnly: true - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: etcceph mountPath: /etc/ceph - name: ceph-etc @@ -206,7 +206,7 @@ spec: secret: secretName: cinder-etc defaultMode: 0444 - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: etcceph emptyDir: {} - name: pod-shared diff --git a/cinder/templates/job-clean.yaml b/cinder/templates/job-clean.yaml old mode 100644 new mode 100755 index 415d41f858..714dc2c128 --- a/cinder/templates/job-clean.yaml +++ b/cinder/templates/job-clean.yaml @@ -16,7 +16,7 @@ limitations under the License. {{- if .Values.manifests.job_clean }} {{- $envAll := . }} -{{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.is_ceph_volume_configured" $envAll) }} +{{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.has_ceph_backend" $envAll) }} {{- $serviceAccountName := print "cinder-clean" }} {{ tuple $envAll "clean" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} @@ -68,7 +68,7 @@ spec: initContainers: {{ tuple $envAll "clean" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} containers: - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: cinder-volume-rbd-secret-clean {{ tuple $envAll "cinder_storage_init" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.jobs.clean | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} diff --git a/cinder/templates/job-storage-init.yaml b/cinder/templates/job-storage-init.yaml old mode 100644 new mode 100755 index 7a0cae06bd..4c13be6ff2 --- a/cinder/templates/job-storage-init.yaml +++ b/cinder/templates/job-storage-init.yaml @@ -65,7 +65,7 @@ spec: {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} initContainers: {{ tuple $envAll "storage_init" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: ceph-keyring-placement {{ tuple $envAll "cinder_storage_init" | include "helm-toolkit.snippets.image" | indent 10 }} securityContext: @@ -97,7 +97,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: STORAGE_BACKEND value: {{ index (index .Values.conf.backends (include "cinder.utils.ceph_volume_section_name" $envAll)) "volume_driver" | quote }} - name: RBD_POOL_NAME @@ -124,7 +124,7 @@ spec: mountPath: /tmp/storage-init.sh subPath: storage-init.sh readOnly: true - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: etcceph mountPath: /etc/ceph - name: ceph-etc @@ -145,7 +145,7 @@ spec: configMap: name: cinder-bin defaultMode: 0555 - {{- if include "cinder.utils.is_ceph_volume_configured" $envAll }} + {{- if include "cinder.utils.has_ceph_backend" $envAll }} - name: etcceph emptyDir: {} - name: ceph-etc diff --git a/cinder/templates/utils/_is_ceph_volume_configured.tpl b/cinder/templates/utils/_has_ceph_backend.tpl similarity index 64% rename from cinder/templates/utils/_is_ceph_volume_configured.tpl rename to cinder/templates/utils/_has_ceph_backend.tpl index 63f2a73aab..0ff7ae5e81 100644 --- a/cinder/templates/utils/_is_ceph_volume_configured.tpl +++ b/cinder/templates/utils/_has_ceph_backend.tpl @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */}} -{{- define "cinder.utils.is_ceph_volume_configured" -}} -{{- range $section, $values := .Values.conf.backends -}} -{{- if kindIs "map" $values -}} -{{- if eq $values.volume_driver "cinder.volume.drivers.rbd.RBDDriver" -}} -true -{{- end -}} -{{- end -}} -{{- end -}} +{{- define "cinder.utils.has_ceph_backend" -}} + {{- $has_ceph := false -}} + {{- range $_, $backend := .Values.conf.backends -}} + {{- if kindIs "map" $backend -}} + {{- $has_ceph = or $has_ceph (eq $backend.volume_driver "cinder.volume.drivers.rbd.RBDDriver") -}} + {{- end -}} + {{- end -}} + {{- $has_ceph -}} {{- end -}}