Rescan disk bus before using volume

In the LAMP stack workload, we found that one issue for interoperability
between clouds was that in some combinations of
hypervisor/adapter/storage is is necessary to rescan the scsi bus of a
guest VM in order to detect a newly attached Cinder volume.[1] We
neglected to do that in the K8s workload, so this patch ammends the
Ansible play that formats the volume to scan the SCSI bus first.

Note that the LAMP workload was targetted toward one guest OS platform
(Ubuntu), and worked by installing the scsitools package and running the
rescan-scsi-bus script that it provides.  The K8s workload is different
in that it's currently targetted toward multiple guests including Ubuntu
and CoreOS [2]...the latter of which doesn't have a package manager.
Rather than build conditionals into the code to handle this, I've taken
a slightly simpler and more platform-agnostic approach in this patch by
simply looking in /sys/class/scsi_host to see what adapters are present
and then scanning each of them with an echo command.  This approach has
a few advantages: 1.) it works on guest OS's in which the name of the
package containing the rescan-scsi-tools script is different than on
Ubuntu, 2.) it works on guest OS's that don't have a package manager at
all, and 3.) since it doesn't require installing any additional
software, it is slightly faster and requires trivially less disk
footprint.

[1] https://review.openstack.org/#/c/383923/
[2] CentOS support is coming too:
https://review.openstack.org/#/c/457199/

Change-Id: Ie7204a23bc7a7d1da9a8cc60e684fc987159a41a
This commit is contained in:
Mark T. Voelker 2017-04-21 14:08:55 -04:00
parent f3eccb7fcc
commit 1cc921cef4
1 changed files with 3 additions and 0 deletions

View File

@ -18,6 +18,9 @@
- stat: path=/tmp/diskflag
register: diskflag
- shell: for adapter in $(echo `find /sys/class/scsi_host -name "host*"`); do echo "- - -" > ${adapter}/scan; done
when: diskflag.stat.exists == false
- shell: parted -s "{{ app_env.block_device_name }}" mklabel msdos
when: diskflag.stat.exists == false