Merge ~kissiel/plainbox-provider-resource:nvme-rotation-fix into plainbox-provider-resource:master

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Sylvain Pineau
Approved revision: d36fa67b2a3bea5c8bb189ce2773a1d82189fad3
Merged at revision: 928e965edb3644d8a3a6710b3f8705409acecdfb
Proposed branch: ~kissiel/plainbox-provider-resource:nvme-rotation-fix
Merge into: plainbox-provider-resource:master
Diff against target: 16 lines (+4/-2)
1 file modified
bin/block_device_resource (+4/-2)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+321386@code.launchpad.net

Description of the change

check if 'rotational' exists before opening for block devices

Which fixes a problem that occurred when running block_device job on NVMe drives.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/block_device_resource b/bin/block_device_resource
2index 1eed9b7..8e97ffb 100755
3--- a/bin/block_device_resource
4+++ b/bin/block_device_resource
5@@ -58,8 +58,10 @@ def device_rotation(name):
6 Check the device queue/rotational parameter to determine if it's a spinning
7 device or a non-spinning device, which indicates it's an SSD.
8 """
9- with open('/sys/block/%s/device/block/%s/queue/rotational' % (name, name),
10- "rt") as f:
11+ path = '/sys/block/{0}/device/block/{0}/queue/rotational'.format(name)
12+ if not os.path.exists(path):
13+ return 'no'
14+ with open(path, "rt") as f:
15 if f.read(1) == '1':
16 return 'yes'
17

Subscribers

People subscribed via source and target branches