OpenMediaVault-Plugin-Developers / openmediavault-zfs

OpenMediaVault plugin for zfs
74 stars 15 forks source link

Root filesystem No such file or directory #82

Closed wallzero closed 2 years ago

wallzero commented 2 years ago

I've installed OMV6 on a root ZFS filesystem. Everything works fine with just the root pool. When mounting a second pool, I get the following error and can't commit the configuration change:

Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; export LANGUAGE=; omv-salt deploy run --no-color collectd 2>&1' with exit code '1': debian:
    Data failed to compile:
----------
    Rendering SLS 'base:omv.deploy.collectd.plugins.disk' failed: Jinja error: [Errno 2] No such file or directory: 'rpool/debian/root'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pyudev/device/_device.py", line 225, in from_device_file
    device_type = get_device_type(filename)
  File "/usr/lib/python3/dist-packages/pyudev/_util.py", line 130, in get_device_type
    mode = os.stat(filename).st_mode
FileNotFoundError: [Errno 2] No such file or directory: 'rpool/debian/root'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/templates.py", line 497, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 64, in top-level template code
  File "/usr/lib/python3/dist-packages/jinja2/sandbox.py", line 465, in call
    return __context.call(__obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 1235, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 2268, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 2283, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/var/cache/salt/minion/extmods/modules/omv_utils.py", line 235, in get_root_filesystem
    return fs.predictable_device_file
  File "/usr/lib/python3/dist-packages/openmediavault/fs/__init__.py", line 193, in predictable_device_file
    if self.has_device_file_by_uuid():
  File "/usr/lib/python3/dist-packages/openmediavault/device/block.py", line 171, in has_device_file_by_uuid
    return is_device_file_by_uuid(self.device_file_by_uuid)
  File "/usr/lib/python3/dist-packages/openmediavault/device/block.py", line 186, in device_file_by_uuid
    for device_link in self.device_links:
  File "/usr/lib/python3/dist-packages/openmediavault/device/block.py", line 89, in device_links
    device = pyudev.Devices.from_device_file(context, self.device_file)
  File "/usr/lib/python3/dist-packages/pyudev/device/_device.py", line 228, in from_device_file
    raise DeviceNotFoundByFileError(err)
pyudev._errors.DeviceNotFoundByFileError: [Errno 2] No such file or directory: 'rpool/debian/root'

; line 64

---
[...]
    {% endif %}
  {% endif %}
{% endfor %}

# Append the root file system.
{% set root_fs = salt['omv_utils.get_root_filesystem']() %}    <======================
{% set disk = salt['omv_utils.get_fs_parent_device_file'](root_fs) %}
{% set _ = disks.append(disk[5:]) %}

configure_collectd_conf_disk_plugin:
  file.managed:
[...]
---

OMV\ExecException: Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; export LANGUAGE=; omv-salt deploy run --no-color collectd 2>&1' with exit code '1': debian:
    Data failed to compile:
----------
    Rendering SLS 'base:omv.deploy.collectd.plugins.disk' failed: Jinja error: [Errno 2] No such file or directory: 'rpool/debian/root'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pyudev/device/_device.py", line 225, in from_device_file
    device_type = get_device_type(filename)
  File "/usr/lib/python3/dist-packages/pyudev/_util.py", line 130, in get_device_type
    mode = os.stat(filename).st_mode
FileNotFoundError: [Errno 2] No such file or directory: 'rpool/debian/root'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/templates.py", line 497, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 64, in top-level template code
  File "/usr/lib/python3/dist-packages/jinja2/sandbox.py", line 465, in call
    return __context.call(__obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 1235, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 2268, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 2283, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/var/cache/salt/minion/extmods/modules/omv_utils.py", line 235, in get_root_filesystem
    return fs.predictable_device_file
  File "/usr/lib/python3/dist-packages/openmediavault/fs/__init__.py", line 193, in predictable_device_file
    if self.has_device_file_by_uuid():
  File "/usr/lib/python3/dist-packages/openmediavault/device/block.py", line 171, in has_device_file_by_uuid
    return is_device_file_by_uuid(self.device_file_by_uuid)
  File "/usr/lib/python3/dist-packages/openmediavault/device/block.py", line 186, in device_file_by_uuid
    for device_link in self.device_links:
  File "/usr/lib/python3/dist-packages/openmediavault/device/block.py", line 89, in device_links
    device = pyudev.Devices.from_device_file(context, self.device_file)
  File "/usr/lib/python3/dist-packages/pyudev/device/_device.py", line 228, in from_device_file
    raise DeviceNotFoundByFileError(err)
pyudev._errors.DeviceNotFoundByFileError: [Errno 2] No such file or directory: 'rpool/debian/root'

; line 64

---
[...]
    {% endif %}
  {% endif %}
{% endfor %}

# Append the root file system.
{% set root_fs = salt['omv_utils.get_root_filesystem']() %}    <======================
{% set disk = salt['omv_utils.get_fs_parent_device_file'](root_fs) %}
{% set _ = disks.append(disk[5:]) %}

configure_collectd_conf_disk_plugin:
  file.managed:
[...]
--- in /usr/share/php/openmediavault/system/process.inc:197
Stack trace:
#0 /usr/share/php/openmediavault/engine/module/serviceabstract.inc(62): OMV\System\Process->execute()
#1 /usr/share/openmediavault/engined/rpc/config.inc(170): OMV\Engine\Module\ServiceAbstract->deploy()
#2 [internal function]: Engined\Rpc\Config->applyChanges(Array, Array)
#3 /usr/share/php/openmediavault/rpc/serviceabstract.inc(123): call_user_func_array(Array, Array)
#4 /usr/share/php/openmediavault/rpc/serviceabstract.inc(149): OMV\Rpc\ServiceAbstract->callMethod('applyChanges', Array, Array)
#5 /usr/share/php/openmediavault/rpc/serviceabstract.inc(588): OMV\Rpc\ServiceAbstract->OMV\Rpc\{closure}('/tmp/bgstatusWw...', '/tmp/bgoutputi0...')
#6 /usr/share/php/openmediavault/rpc/serviceabstract.inc(159): OMV\Rpc\ServiceAbstract->execBgProc(Object(Closure))
#7 /usr/share/openmediavault/engined/rpc/config.inc(192): OMV\Rpc\ServiceAbstract->callMethodBg('applyChanges', Array, Array)
#8 [internal function]: Engined\Rpc\Config->applyChangesBg(Array, Array)
#9 /usr/share/php/openmediavault/rpc/serviceabstract.inc(123): call_user_func_array(Array, Array)
#10 /usr/share/php/openmediavault/rpc/rpc.inc(86): OMV\Rpc\ServiceAbstract->callMethod('applyChangesBg', Array, Array)
#11 /usr/sbin/omv-engined(537): OMV\Rpc\Rpc::call('Config', 'applyChangesBg', Array, Array, 1)
#12 {main}

It complains No such file or directory: 'rpool/debian/root' which is the root pool. But the configuration and root pool work fine until I try to import a second pool.

ryecoaaron commented 2 years ago

I have three pools on my test system with no issues. What is the output of: sudo zfs list

wallzero commented 2 years ago

There are a lot of file systems in the output list including docker images. I'd rather not show the whole thing. But the root file system is there:

rpool/debian/root                                                                          2.00G  20.0G     2.00G  /

Is one of your three pools acting as a root file system?

ryecoaaron commented 2 years ago

Nope. That probably is the issue. Never even tested the plugin against zfs on root. You will probably have to disable monitoring (not part of the zfs plugin) to have root zfs.

As for output, I don't need it this time (didn't notice that you were trying to use zfs on root in the original post) but try being an admin on a system where commands only give you 10% of the output.

wallzero commented 2 years ago

Disabling monitoring had no effect. But changing monitoring did throw the same error whether I had a second pool mounted or not. So I suspect an additional imported pool isn't the issue.

In the meantime I did something hacky to allow the config generation to complete:

### /var/cache/salt/minion/extmods/modules/omv_utils.py:235

def get_root_filesystem():
    """
    Get the device file of the root filesystem, e.g. '/dev/sda1'.
    :return: The device file of the root filesystem.
    :rtype: str
    """
    fs = openmediavault.fs.Filesystem.from_mount_point('/')
    # return fs.predictable_device_file
    return "rpool/debian/root"

I think the issue is OMV is trying to find a device file while ZFS filesystems don't really have one. I'll see if the above change has any negative impact on my setup.

ryecoaaron commented 2 years ago

That will cause other issues. The real solution is to not use zfs for root. I see little reason to. You can use btrfs or lvm if you want snapshots.

ryecoaaron commented 2 years ago

The collectd is error is monitoring though. It may not be able to disable monitoring with zfs root. Either way, this is not something the zfs plugin can fix. So, I will close the ticket. This can be discussed further in the forum where more people will see it.