block_device_resource script incorrectly sets hot-swap HDDs as "removable" causing disk tests to not run
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Checkbox Provider - Resource |
Fix Released
|
Critical
|
Jeff Lane |
Bug Description
The current block_device_
def device_state(name):
"""Follow pmount policy to find if a device is removable or internal."""
with open('/
"rt") as f:
if f.read(1) == '1':
return 'removable'
path = rootdir_
hotplug_buses = ("usb", "ieee1394", "mmc", "pcmcia", "firewire")
for bus in hotplug_buses:
if os.path.
for device_bus in os.listdir(
if re.search(
return 'internal'
The first match causes any hot-swap hard drives as you'd find in any hostswap capable server... because technically, hot-swap HDDs ARE removable, BUT they're also considered "internal". Because of this, the HDD tests are being skipped because device.state is set to "removable" for these hot-swap HDDs.
Here's what it looks like in practice on the system we discovered this on:
sda: first clause
sda_state: removable
sda_usb2: unsupported
sda_usb3: unsupported
sda_rotation: yes
sda_smart: False
sdb: first clause
sdb_state: removable
sdb_usb2: unsupported
sdb_usb3: unsupported
sdb_rotation: yes
sdb_smart: False
sdc: first clause
sdc_state: removable
sdc_usb2: supported
sdc_usb3: supported
sdc_rotation: yes
sdc_smart: False
sdd: first clause
sdd_state: removable
sdd_usb2: supported
sdd_usb3: unsupported
sdd_rotation: yes
sdd_smart: False
Note the "first clause" entry is a tracer I put in to figure out which of the two code branches were causing the problem. sda and sdb are both spinning HDDs, but both are in hot-swap bays with hot-swap enabled (can't be disabled). Because sda|sdb_state is "removable", the various disk/* tests that depend on device.state != "removable" all get skipped.
If I remove that first code block that simply checks sys/...
sda_state: internal
sda_usb2: unsupported
sda_usb3: unsupported
sda_rotation: yes
sda_smart: False
sdb_state: internal
sdb_usb2: unsupported
sdb_usb3: unsupported
sdb_rotation: yes
sdb_smart: False
sdc_state: removable
sdc_usb2: supported
sdc_usb3: supported
sdc_rotation: yes
sdc_smart: False
sdd_state: removable
sdd_usb2: supported
sdd_usb3: unsupported
sdd_rotation: yes
sdd_smart: False
Now it correctly identifies my two HDDs as internal (because they're not on the list of hot pluggable busses in the second code block), and the two USB devices are correctly identified as "removable".
Related branches
- Sylvain Pineau (community): Approve
- Paul Larson: Pending requested
- Pierre Equoy: Pending requested
- Diff: 0 lines
tags: |
added: blocks-hwcert-server removed: hwcert-server |
Changed in plainbox-provider-resource: | |
status: | In Progress → Fix Released |
I have a patch for this that simply removes that first block. I toyed around with other things, like adding this to the second block, and moving that to first place,
def device_state(name):
"""Follow pmount policy to find if a device is removable or internal."""
path = rootdir_ pattern. sub('', os.readlink( '/sys/block/ %s' % name)) exists( '/sys/bus/ %s' % bus): '/sys/bus/ %s/devices' % bus):
device_ link = rootdir_ pattern. sub('', os.readlink(
' /sys/bus/ %s/devices/ %s' % (bus, device_bus))) device_ link, path):
print( "path: %s" % path)
print( "device_ link: %s" % device_link)
print( "device_ bus: %s" % device_bus)
return 'internal'
elif re.search( device_ link, path):
return 'removable'
hotplug_buses = ("scsi", "usb", "ieee1394", "mmc", "pcmcia", "firewire")
for bus in hotplug_buses:
if os.path.
for device_bus in os.listdir(
if bus == "scsi" and re.search(
with open('/ sys/block/ %s/device/ block/% s/removable' % (name, name),
"rt") as f:
if f.read(1) == '1':
return 'removable'
return 'internal'
This doesn't work though, because USB devices are ALSO on the scsi bus.
In the end, simply removing that check for /sys/block/ %s/device/ block/% s/removable fixes the issue.
So I wonder why that check is even there...
what cases are there where a device on "usb", "ieee1394", "mmc", "pcmcia", "firewire" busses are NOT removable? I can't think of any...
However, as this likely can affect client testing I want to make sure this is reasonable, and am open to suggestions if there's a better way to ID actual HDDs vs removabe storage devices in block_device_ resource.
I do, however, need this fix pretty fast-like, as it IS a blocker on any server with active hot-swap drives.
Note, this does NOT affect hardware RAID setups with hot-swap drives. In that case, the RAID controller presents a non-removable LUN to the OS, and handles the removability of the drive internally to itself.