clear-holder fails reading missing dir in sysfs during tear-down

Bug #1782016 reported by Ryan Harper
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
curtin
In Progress
Medium
Unassigned

Bug Description

During vmtest runs, when tearing down layered bcache devices, we encounter a race condition when looking for block device holders. Curtin issues various shutdown commands to bcache layers and when the kernel stops and removes the device, the sysfs path to the 'holders' subdir is no longer valid.

This list comprehension of collecting paths from an os.listdir() on a non-existent sysfspath throws an OSError.

 Traceback (most recent call last):
   File "/curtin/curtin/commands/main.py", line 201, in main
     ret = args.func(args)
   File "/curtin/curtin/commands/block_meta.py", line 58, in block_meta
     meta_custom(args)
   File "/curtin/curtin/commands/block_meta.py", line 1473, in meta_custom
     clear_holders.assert_clear(disk_paths)
   File "/curtin/curtin/block/clear_holders.py", line 544, in assert_clear
     for holders_tree in [gen_holders_tree(p) for p in base_paths]:
   File "/curtin/curtin/block/clear_holders.py", line 544, in <listcomp>
     for holders_tree in [gen_holders_tree(p) for p in base_paths]:
   File "/curtin/curtin/block/clear_holders.py", line 443, in gen_holders_tree
     'holders': [gen_holders_tree(h) for h in holder_paths],
   File "/curtin/curtin/block/clear_holders.py", line 443, in <listcomp>
     'holders': [gen_holders_tree(h) for h in holder_paths],
   File "/curtin/curtin/block/clear_holders.py", line 427, in gen_holders_tree
     holder_paths = ([block.sys_block_path(h) for h in get_holders(device)] +
   File "/curtin/curtin/block/clear_holders.py", line 412, in get_holders
     holders = os.listdir(os.path.join(sysfs_path, 'holders'))

The fix here is to:

1) log the error
2) if the exception is an OSError (filenotfound) then we'll ignore it as the device was expected to be deleted.

Ryan Harper (raharper)
Changed in curtin:
importance: Undecided → Medium
status: New → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.