Cinder: Support backup driver specification by module or class name

During the Queens cycle, Cinder introduced the ability to specify the
backup driver via class name and deprecated backup driver initialization
using the module name. (Id6bee9e7d0da8ead224a04f86fe79ddfb5b286cf)

Legacy support for initialization by module name was dropped in Stein.
(I3ada2dee1857074746b1893b82dd5f6641c6e579)

This change will support both methods of initialization and leave the
driver defaults enabled for module based initialization (valid through
Rocky images).

This change has been tested using the OSH default Cinder (Ocata) images
and StarlingX images based on master (Train).

Change-Id: Iec7bc6f4dd089aaa08ca652bebd9a10ef49da556
Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
Robert Church 2019-05-24 02:43:15 -04:00
parent 89f5bfe3ac
commit aa4ca5ad56
7 changed files with 24 additions and 20 deletions

View File

@ -17,7 +17,7 @@ limitations under the License.
*/}}
set -x
if [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.ceph" ]; then
if [[ $STORAGE_BACKEND =~ 'cinder.backup.drivers.ceph' ]]; then
SECRET=$(mktemp --suffix .yaml)
KEYRING=$(mktemp --suffix .keyring)
function cleanup {
@ -27,10 +27,10 @@ if [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.ceph" ]; then
fi
set -ex
if [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.swift" ] || \
[ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.posix" ]; then
if [[ $STORAGE_BACKEND =~ 'cinder.backup.drivers.swift' ]] || \
[[ $STORAGE_BACKEND =~ 'cinder.backup.drivers.posix' ]]; then
echo "INFO: no action required to use $STORAGE_BACKEND"
elif [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.ceph" ]; then
elif [[ $STORAGE_BACKEND =~ 'cinder.backup.drivers.ceph' ]]; then
ceph -s
function ensure_pool () {
ceph osd pool stats $1 || ceph osd pool create $1 $2

View File

@ -63,7 +63,7 @@ limitations under the License.
{{- $_ := tuple "image" "internal" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup"| set .Values.conf.cinder.DEFAULT "glance_api_servers" -}}
{{- end -}}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.swift" }}
{{- if (contains "cinder.backup.drivers.swift" .Values.conf.cinder.DEFAULT.backup_driver) }}
{{- if empty .Values.conf.cinder.DEFAULT.backup_swift_auth_version -}}
{{- $_ := set .Values.conf.cinder.DEFAULT "backup_swift_auth_version" "3" -}}
{{- end -}}

View File

@ -54,7 +54,7 @@ spec:
{{ .Values.labels.backup.node_selector_key }}: {{ .Values.labels.backup.node_selector_value }}
initContainers:
{{ tuple $envAll "backup" $mounts_cinder_backup_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: ceph-backup-keyring-placement
{{ tuple $envAll "cinder_backup" | include "helm-toolkit.snippets.image" | indent 10 }}
securityContext:
@ -102,7 +102,7 @@ spec:
subPath: key
readOnly: true
{{ end }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.posix" }}
{{- if (contains "cinder.backup.drivers.posix" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: ceph-backup-volume-perms
{{ 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 (eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph") (include "cinder.utils.is_ceph_volume_configured" $envAll) }}
{{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.is_ceph_volume_configured" $envAll) }}
- name: etcceph
mountPath: /etc/ceph
{{- if not .Values.backup.external_ceph_rbd.enabled }}
@ -176,7 +176,7 @@ spec:
subPath: external-backup-ceph.conf
readOnly: true
{{- end }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: ceph-backup-keyring
mountPath: /tmp/client-keyring
subPath: key
@ -188,7 +188,7 @@ spec:
readOnly: true
{{- end }}
{{- end }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.posix" }}
{{- if (contains "cinder.backup.drivers.posix" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: cinder-backup
mountPath: {{ .Values.conf.cinder.DEFAULT.backup_posix_path }}
{{- end }}
@ -227,7 +227,7 @@ spec:
configMap:
name: cinder-bin
defaultMode: 0555
{{ if or (eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph") (include "cinder.utils.is_ceph_volume_configured" $envAll) }}
{{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.is_ceph_volume_configured" $envAll) }}
- name: etcceph
emptyDir: {}
- name: ceph-etc
@ -235,7 +235,7 @@ spec:
name: {{ .Values.ceph_client.configmap }}
defaultMode: 0444
{{ end }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: ceph-backup-keyring
secret:
secretName: {{ .Values.secrets.rbd.backup | quote }}
@ -245,7 +245,7 @@ spec:
secret:
secretName: {{ .Values.secrets.rbd.volume | quote }}
{{ end }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.posix" }}
{{- if (contains "cinder.backup.drivers.posix" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: cinder-backup
persistentVolumeClaim:
claimName: cinder-backup

View File

@ -67,7 +67,7 @@ spec:
{{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
initContainers:
{{ tuple $envAll "backup_storage_init" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: ceph-keyring-placement
{{ tuple $envAll "cinder_backup_storage_init" | include "helm-toolkit.snippets.image" | indent 10 }}
securityContext:
@ -108,7 +108,7 @@ spec:
fieldPath: metadata.namespace
- name: STORAGE_BACKEND
value: {{ .Values.conf.cinder.DEFAULT.backup_driver | quote }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: RBD_POOL_NAME
value: {{ .Values.conf.cinder.DEFAULT.backup_ceph_pool | quote }}
- name: RBD_POOL_APP_NAME
@ -133,7 +133,7 @@ spec:
mountPath: /tmp/backup-storage-init.sh
subPath: backup-storage-init.sh
readOnly: true
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: etcceph
mountPath: /etc/ceph
{{- if not .Values.backup.external_ceph_rbd.enabled }}
@ -161,7 +161,7 @@ spec:
configMap:
name: cinder-bin
defaultMode: 0555
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: etcceph
emptyDir: {}
- name: ceph-etc

View File

@ -16,7 +16,7 @@ limitations under the License.
{{- if .Values.manifests.job_clean }}
{{- $envAll := . }}
{{ if or (eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph") (include "cinder.utils.is_ceph_volume_configured" $envAll) }}
{{ if or (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) (include "cinder.utils.is_ceph_volume_configured" $envAll) }}
{{- $serviceAccountName := print "cinder-clean" }}
{{ tuple $envAll "clean" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
@ -89,7 +89,7 @@ spec:
subPath: clean-secrets.sh
readOnly: true
{{ end }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.ceph" }}
{{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
- name: cinder-volume-backup-secret-clean
{{ tuple $envAll "cinder_backup_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 }}

View File

@ -16,7 +16,7 @@ limitations under the License.
{{- if .Values.manifests.pvc_backup }}
{{- $envAll := . }}
{{- if eq .Values.conf.cinder.DEFAULT.backup_driver "cinder.backup.drivers.posix" }}
{{- if (contains "cinder.backup.drivers.posix" .Values.conf.cinder.DEFAULT.backup_driver) }}
---
kind: PersistentVolumeClaim
apiVersion: v1

View File

@ -793,6 +793,10 @@ conf:
default_volume_type: "rbd1"
# NOTE(portdirect): "cinder.backup.drivers.ceph" and
# "cinder.backup.drivers.posix" also supported
# NOTE(rchurch): As of Stein, drivers by class name are required
# - cinder.backup.drivers.swift.SwiftBackupDriver
# - cinder.backup.drivers.ceph.CephBackupDriver
# - cinder.backup.drivers.posix.PosixBackupDriver
backup_driver: "cinder.backup.drivers.swift"
# Backup: Ceph RBD options
backup_ceph_conf: "/etc/ceph/ceph.conf"