Ensure cinder LVM volumes work after system restart

Update the cinder-lvm-losetup systemd service to wait until the local
/var directory is mounted and the lvm2-monitor service has started
prior to creating the loopback device used by cinder's LVM backend.

Make LIO SCSI target data persistent by adding container volume mounts
for the /etc/target directory so that the data is stored on the host.

Closes-Bug: #1905617
Change-Id: I0c0cbed3a41e8d4b1fbaf5c2dc7fd0412fee644a
(cherry picked from commit 63b2a989ba)
(cherry picked from commit 27678af1ab)
This commit is contained in:
Alan Bishop 2020-11-24 09:09:04 -08:00
parent f87ded0343
commit 833e812baf
2 changed files with 17 additions and 11 deletions

View File

@ -76,6 +76,7 @@ parameters:
conditions: conditions:
cinder_iscsi_backend_enabled: {equals: [{get_param: CinderEnableIscsiBackend}, true]}
multipathd_enabled: {equals: [{get_param: MultipathdEnable}, true]} multipathd_enabled: {equals: [{get_param: MultipathdEnable}, true]}
cvol_active_active_tls_enabled: cvol_active_active_tls_enabled:
and: and:
@ -130,7 +131,7 @@ outputs:
- -
- name: cinder_enable_iscsi_backend fact - name: cinder_enable_iscsi_backend fact
set_fact: set_fact:
cinder_enable_iscsi_backend: {get_param: CinderEnableIscsiBackend} cinder_enable_iscsi_backend: {if: [cinder_iscsi_backend_enabled, true, false]}
- when: cinder_enable_iscsi_backend|bool - when: cinder_enable_iscsi_backend|bool
block: block:
- name: ensure LVM rpm dependencies are installed - name: ensure LVM rpm dependencies are installed
@ -180,9 +181,9 @@ outputs:
Description=Cinder LVM losetup Description=Cinder LVM losetup
DefaultDependencies=no DefaultDependencies=no
Conflicts=umount.target Conflicts=umount.target
Requires=lvm2-lvmetad.service systemd-udev-settle.service Requires=lvm2-monitor.service systemd-udev-settle.service
Before=local-fs.target umount.target Before=local-fs.target umount.target
After=lvm2-lvmetad.service systemd-udev-settle.service After=var.mount lvm2-monitor.service systemd-udev-settle.service
[Service] [Service]
Type=oneshot Type=oneshot
@ -216,6 +217,11 @@ outputs:
- /sys:/sys - /sys:/sys
- /var/lib/cinder:/var/lib/cinder:z - /var/lib/cinder:/var/lib/cinder:z
- /var/lib/iscsi:/var/lib/iscsi:z - /var/lib/iscsi:/var/lib/iscsi:z
-
if:
- cinder_iscsi_backend_enabled
- - /etc/target:/etc/target:z
- []
- -
if: if:
- multipathd_enabled - multipathd_enabled

View File

@ -142,20 +142,20 @@ outputs:
- /sys:/sys - /sys:/sys
- /lib/modules:/lib/modules:ro - /lib/modules:/lib/modules:ro
- /etc/iscsi:/var/lib/kolla/config_files/src-iscsid:ro - /etc/iscsi:/var/lib/kolla/config_files/src-iscsid:ro
- /etc/target:/etc/target:z
- /var/lib/iscsi:/var/lib/iscsi:z - /var/lib/iscsi:/var/lib/iscsi:z
environment: environment:
KOLLA_CONFIG_STRATEGY: COPY_ALWAYS KOLLA_CONFIG_STRATEGY: COPY_ALWAYS
host_prep_tasks: host_prep_tasks:
- name: ensure /etc/iscsi exists - name: create persistent directories
file: file:
path: /etc/iscsi path: "{{ item.path }}"
state: directory state: directory
setype: container_file_t setype: "{{ item.setype }}"
- name: ensure /var/lib/iscsi exists with_items:
file: - { 'path': /etc/iscsi, 'setype': container_file_t }
path: /var/lib/iscsi - { 'path': /etc/target, 'setype': container_file_t }
state: directory - { 'path': /var/lib/iscsi, 'setype': container_file_t }
setype: container_file_t
- name: stat /lib/systemd/system/iscsid.socket - name: stat /lib/systemd/system/iscsid.socket
stat: path=/lib/systemd/system/iscsid.socket stat: path=/lib/systemd/system/iscsid.socket
register: stat_iscsid_socket register: stat_iscsid_socket