Do not fail on unexpected blkid output
On certain conditions, storage backend fails on unexpected blkid
output.
Extra:
{"module": "storage", "action": "get_drives", "kind": "request"}
Trace:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/foris_controller/message_router.py", line 117, in process_message
File "/usr/lib/python3.9/site-packages/foris_controller/module_base.py", line 61, in perform_action
File "/usr/lib/python3.9/site-packages/foris_controller_modules/storage/__init__.py", line 27, in action_get_drives
File "/usr/lib/python3.9/site-packages/foris_controller/utils.py", line 113, in inner
File "/usr/lib/python3.9/site-packages/foris_controller_modules/storage/handlers/openwrt.py", line 27, in get_drives
File "/usr/lib/python3.9/site-packages/foris_controller_backends/storage/__init__.py", line 164, in get_drives ValueError: not enough values to unpack (expected 2, got 1)
In file storage/__init__.py:164
, we try to parse string in following format:
/dev/<device>: ATTRIBUTE1="..." "ATTRIBUTE2="..."
For example:
root@mox-AC-1G:/# blkid /dev/mmcblk0p1
/dev/mmcblk0p1: UUID="0852093a-111f-4bdc-b9c2-c9a16a192e7b" UUID_SUB="77772223-6724-4c5f-a83f-3a42827cd9e6" BLOCK_SIZE="4096" TYPE="btrfs"
However it may fail on string that does not contain character ":", which is used as delimiter.
See: https://gitlab.nic.cz/turris/foris-controller/foris-controller-storage-module/-/blob/master/foris_controller_backends/storage/init.py#L158
It would be nice to have more resilient reading of blkid output.
How to reproduce
- TOS 6.0
- Mox ABC with NVMe drive in module B
- USB flash drive plugged into Mox A
Edited by Martin Matějek