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 <daniel.badea@windriver.com>.
This commit is contained in:
Daniel Badea 2019-06-20 14:02:32 +00:00
parent a8c8b74f69
commit 80a14e940e
5 changed files with 21 additions and 21 deletions

8
cinder/templates/deployment-backup.yaml Normal file → Executable file
View File

@ -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 }}

6
cinder/templates/deployment-volume.yaml Normal file → Executable file
View File

@ -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

4
cinder/templates/job-clean.yaml Normal file → Executable file
View File

@ -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 }}

8
cinder/templates/job-storage-init.yaml Normal file → Executable file
View File

@ -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

View File

@ -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 -}}