From 0b5b09c123a40a3f68cd8fb6be2f8da9fe91f31a Mon Sep 17 00:00:00 2001 From: Alan Bishop Date: Wed, 12 May 2021 12:19:51 -0700 Subject: [PATCH] Support cinder image conversion on an NFS share New CinderImageConversionNfsShare and CinderImageConversionNfsOptions parameters add support for mounting an external NFS share for cinder to use when converting glance images to or from another format (e.g. qcow2 versus raw). This feature is useful in preventing the node's root disk from filling up in situations where the available disk space is too small, which can happen in deployments that utilize very large glance images. Change-Id: If7b3640191d84e5cf30cbbcb1cc94aa0f068d11c (cherry picked from commit 2225f9666b157de773fc1dadf195034e24e2577b) (cherry picked from commit d5b8ced547f5bf163b7ef76ef82a687af61434f9) --- .../cinder-common-container-puppet.yaml | 61 ++++++++++++++++++- .../cinder-volume-container-puppet.yaml | 3 +- ...r-nfs-conversion-dir-ba9b8dce515808ce.yaml | 8 +++ 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/cinder-nfs-conversion-dir-ba9b8dce515808ce.yaml diff --git a/deployment/cinder/cinder-common-container-puppet.yaml b/deployment/cinder/cinder-common-container-puppet.yaml index eb33afa2e4..74bdfb401e 100644 --- a/deployment/cinder/cinder-common-container-puppet.yaml +++ b/deployment/cinder/cinder-common-container-puppet.yaml @@ -64,6 +64,16 @@ parameters: be managed by pacemaker. If these criteria are not met then the cluster name must be left blank. type: string + CinderImageConversionNfsShare: + default: '' + description: When set, the NFS share to be used for Cinder's image conversion + directory. + type: string + CinderImageConversionNfsOptions: + default: '_netdev,bg,intr,context=system_u:object_r:container_file_t:s0' + description: NFS mount options when using an NFS share for Cinder's image + conversion directory. + type: string EnableInternalTLS: type: boolean default: false @@ -124,12 +134,25 @@ conditions: - equals: [{get_param: EnableInternalTLS}, true] - equals: [{get_param: EnableEtcdInternalTLS}, true] + cinder_nfs_conversion_dir_enabled: + not: + equals: + - {get_param: CinderImageConversionNfsShare} + - '' + resources: ContainersCommon: type: ../containers-common.yaml outputs: + cinder_image_conversion_nfs_dir: + description: The directory where cinder does its image conversion when the + directory is backed by an NFS share. + value: &cinder_image_conversion_nfs_dir + # Avoid SELinux conflicts by choosing a location outside /var/lib/cinder + /var/lib/cinder_image_conversion + cinder_common_host_prep_tasks: description: Common host prep tasks for cinder-volume and cinder-backup services value: &cinder_common_host_prep_tasks @@ -221,7 +244,26 @@ outputs: value: list_concat: - *cinder_common_host_prep_tasks - - + - - name: Support using an NFS share for cinder image conversion + vars: + image_conversion_nfs_enabled: {if: [cinder_nfs_conversion_dir_enabled, true, false]} + when: + - image_conversion_nfs_enabled|bool + block: + - name: Create cinder image conversion directory + file: + path: *cinder_image_conversion_nfs_dir + state: directory + - name: Mount cinder's image conversion NFS share + vars: + image_conversion_nfs_share: {get_param: CinderImageConversionNfsShare} + image_conversion_nfs_options: {get_param: CinderImageConversionNfsOptions} + mount: + path: *cinder_image_conversion_nfs_dir + state: mounted + fstype: nfs4 + src: "{{ image_conversion_nfs_share }}" + opts: "{{ image_conversion_nfs_options }}" - name: cinder_enable_iscsi_backend fact set_fact: cinder_enable_iscsi_backend: {if: [cinder_iscsi_backend_enabled, true, false]} @@ -294,6 +336,14 @@ outputs: enabled: yes daemon_reload: yes + cinder_volume_config_settings: + description: Config settings for the cinder-volume container (HA or non-HA) + value: + if: + - cinder_nfs_conversion_dir_enabled + - cinder::image_conversion_dir: *cinder_image_conversion_nfs_dir + - {} + cinder_volume_volumes: description: Volumes for the cinder-volume container (HA or non-HA) value: @@ -321,6 +371,15 @@ outputs: - - /etc/multipath:/etc/multipath:z - /etc/multipath.conf:/etc/multipath.conf:ro - [] + - if: + - cinder_nfs_conversion_dir_enabled + - - str_replace: + # Use slave propagation so if the mount is delayed on the host + # it will also be updated within the cinder-volume container. + template: DIR:DIR:slave + params: + DIR: *cinder_image_conversion_nfs_dir + - [] cinder_volume_environment: description: Docker environment for the cinder-volume container (HA or non-HA) diff --git a/deployment/cinder/cinder-volume-container-puppet.yaml b/deployment/cinder/cinder-volume-container-puppet.yaml index 21641549d4..4518a4f8b8 100644 --- a/deployment/cinder/cinder-volume-container-puppet.yaml +++ b/deployment/cinder/cinder-volume-container-puppet.yaml @@ -218,8 +218,9 @@ outputs: config_settings: map_merge: - get_attr: [CinderBase, role_data, config_settings] + - get_attr: [CinderCommon, cinder_volume_config_settings] - tripleo::profile::base::lvm::enable_udev: false - - tripleo::profile::base::cinder::volume::cinder_enable_iscsi_backend: {get_param: CinderEnableIscsiBackend} + tripleo::profile::base::cinder::volume::cinder_enable_iscsi_backend: {get_param: CinderEnableIscsiBackend} tripleo::profile::base::cinder::volume::cinder_enable_nfs_backend: {get_param: CinderEnableNfsBackend} tripleo::profile::base::cinder::volume::cinder_enable_rbd_backend: {get_param: CinderEnableRbdBackend} tripleo::profile::base::cinder::volume::cinder_volume_cluster: {get_param: CinderVolumeCluster} diff --git a/releasenotes/notes/cinder-nfs-conversion-dir-ba9b8dce515808ce.yaml b/releasenotes/notes/cinder-nfs-conversion-dir-ba9b8dce515808ce.yaml new file mode 100644 index 0000000000..700374122a --- /dev/null +++ b/releasenotes/notes/cinder-nfs-conversion-dir-ba9b8dce515808ce.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + The following parameters add support for mounting Cinder's image + conversion directory on an external NFS share. + + * CinderImageConversionNfsShare + * CinderImageConversionNfsOptions