Hide Forgot
Description of problem: When attempting to import the fs plugin, sample script fails. Same import with lvm plugin succeeds. Version-Release number of selected component (if applicable): [root@localhost libblockdev]# rpm -qa | grep blockdev libblockdev-utils-2.19-6.el8.x86_64 libblockdev-fs-2.19-6.el8.x86_64 libblockdev-nvdimm-2.19-6.el8.x86_64 libblockdev-kbd-2.19-6.el8.x86_64 libblockdev-mdraid-2.19-6.el8.x86_64 libblockdev-2.19-6.el8.x86_64 libblockdev-lvm-2.19-6.el8.x86_64 libblockdev-part-2.19-6.el8.x86_64 libblockdev-loop-2.19-6.el8.x86_64 libblockdev-vdo-2.19-6.el8.x86_64 libblockdev-swap-2.19-6.el8.x86_64 libblockdev-dm-2.19-6.el8.x86_64 python3-blockdev-2.19-6.el8.x86_64 libblockdev-crypto-2.19-6.el8.x86_64 libblockdev-mpath-2.19-6.el8.x86_64 libblockdev-plugins-all-2.19-6.el8.x86_64 Steps to Reproduce: Script contents: ================ [root@localhost libblockdev]# cat sample_script.py #!/usr/bin/python3 import sys import os import gi gi.require_version("GLib", "2.0") gi.require_version("BlockDev", "2.0") from gi.repository import GLib from gi.repository import BlockDev as bd REQUESTED_PLUGIN_NAMES = {"fs"} requested_plugins = bd.plugin_specs_from_names(REQUESTED_PLUGIN_NAMES) try: succ_ = bd.init(requested_plugins) except GLib.GError as err: raise RuntimeError("Failed to initialize libbd and its plugins (%s)" % REQUESTED_PLUGIN_NAMES) Execution failure: ================== [root@localhost libblockdev]# ./sample_script.py ** (process:31170): WARNING **: 17:53:59.004: The 'ntfscluster' utility is not available The 'ntfslabel' utility is not available The 'ntfsresize' utility is not available The 'ntfsfix' utility is not available The 'mkntfs' utility is not available Traceback (most recent call last): File "./sample_script.py", line 18, in <module> succ_ = bd.init(requested_plugins) File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 91, in init return _init(require_plugins, log_func) GLib.Error: g-bd-init-error-quark: Failed to load plugins (0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./sample_script.py", line 20, in <module> raise RuntimeError("Failed to initialize libbd and its plugins (%s)" % REQUESTED_PLUGIN_NAMES) RuntimeError: Failed to initialize libbd and its plugins ({'fs'}) lvm plugin works fine: ====================== [root@localhost libblockdev]# sed -i 's/"fs"/"lvm"/g' sample_script.py [root@localhost libblockdev]# ./sample_script.py Actual results: fs Plugin import fails Expected results: fs Plugin import should succeed Additional Info: Sample script structure taken from https://github.com/storaged-project/api-examples/blob/master/demo-1-libblockdev-python
Tested the other plugins that I could find and they all succeeded. lvm - pass fs - fail nvdimm - pass kbd - pass mdraid - pass part - pass loop - pass vdo - pass swap - pass dm - pass crypto - pass mpath - pass
I reproduced this issue with sample_script.py for libblockdev-2.19-6.el8, let me add ACK+. DISTRO=RHEL-8.0-20181220.1 ARCHITECTURE=x86_64 --------------------------------------- # rpm -qa|egrep 'libblockdev-[0-9]|python3-blockdev' libblockdev-2.19-6.el8.x86_64 python3-blockdev-2.19-6.el8.x86_64 # python sample_script.py ** (process:30631): WARNING **: 00:30:16.665: The 'fsck.vfat' utility is not available The 'fatlabel' utility is not available The 'mkfs.vfat' utility is not available Traceback (most recent call last): File "sample_script.py", line 18, in <module> succ_ = bd.init(requested_plugins) File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 91, in init return _init(require_plugins, log_func) GLib.Error: g-bd-init-error-quark: Failed to load plugins (0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "sample_script.py", line 20, in <module> raise RuntimeError("Failed to initialize libbd and its plugins (%s)" % REQUESTED_PLUGIN_NAMES) RuntimeError: Failed to initialize libbd and its plugins ({'fs'}) # uname -r 4.18.0-56.el8.x86_64 # cat /etc/redhat-release Red Hat Enterprise Linux release 8.0 Beta (Ootpa)
This is actually expected behavior. Libblockdev has checks for runtime dependencies during init by default and init fails if the dependencies are not available. You can use the "bd_switch_init_checks" function to disable this behavior. I've updated the API examples to do this by default -- https://github.com/storaged-project/api-examples/pull/6
I didn't find the issue on latest version of libblockdev-2.19-7.el8, libblockdev fs plugin can be loaded successfully in my testing. We can Resolve current bug. test.py ------------ #!/usr/bin/python3 import sys import os import gi gi.require_version("GLib", "2.0") gi.require_version("BlockDev", "2.0") from gi.repository import GLib from gi.repository import BlockDev as bd REQUESTED_PLUGIN_NAMES = {"fs"} requested_plugins = bd.plugin_specs_from_names(REQUESTED_PLUGIN_NAMES) # disable checks for runtime dependencies during init -- thanks to this init # won't fail if for example 'mke2fs' is not installed bd.switch_init_checks(False) try: succ_ = bd.init(requested_plugins) except GLib.GError as err: raise RuntimeError("Failed to initialize libbd and its plugins (%s)" % REQUESTED_PLUGIN_NAMES)
Closing based on comment #4. Please to reopen the bug if you encounter the issue again.