Skip to content

Commit 5adc280

Browse files
committed
Rescan PCI bus to allow outdated NVMe drivers to discover volumes.
With CentOS 6 AMIs that have an outdated NVMe driver, we need to force a rescan of the PCI bus after attaching an EBS volume so the driver can attach to it. The rescan should not be harmful for other platforms, so triggering it unconditionally. Implementing it here as the rescan has to be done after the boto call has been made to attach a volume (from attachVolume.py) while polling for the device so the rescan can cause our udev rule to kick in for /dev/disk/by-ebs-volumeid. Signed-off-by: Raghu Raja <craghun@amazon.com>
1 parent 763f0b4 commit 5adc280

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

libraries/helpers.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@
77
#
88
def wait_for_block_dev(path)
99
Timeout.timeout(60) do
10-
sleep(1) until ::File.blockdev?(path)
10+
until ::File.blockdev?(path)
11+
sleep(5)
12+
rescan_pci()
13+
end
1114
Chef::Log.debug("device ${path} not ready - sleeping 1s")
1215
end
1316
end
1417

18+
#
19+
# Rescan the PCI bus to discover newly added volumes.
20+
#
21+
def rescan_pci()
22+
Mixlib::ShellOut.new("echo 1 > /sys/bus/pci/rescan").run_command
23+
end
24+
1525
#
1626
# Format a block device using the EXT4 file system if it is not already
1727
# formatted.

0 commit comments

Comments
 (0)