{'host_str': ['Invalid host string: 192.168.1.0/24']}

[Please complete the below template with details of the problem reported on your Web-UI. Be as detailed as possible. Community members, including developers, shall try and help. Thanks for your time in reporting this issue! We recommend purchasing commercial support for expedited support directly from the developers.]

Brief description of the problem

Attempting to create a NFS export with access for subnet fails.

NB. I noticed this issue first in testing version 5.0.15-0. However it may have first happened before this as I do not create NFS shares very often.

Detailed step by step instructions to reproduce the problem

Attempted to create a NFS export with access for subnet 192.168.1.0/24 fails.

I can create the export with a single ip address without the subnet mask included (e.g. 192.168.1.100).

A share created in an older (unknown version number) worked.

This is not a major issue for me as I can edit /etc/exports and then everything works, although the Web GUI still shows the single ip address I entered to check that that worked.

Web-UI screenshot

Error Traceback provided on the Web-UI

Traceback (most recent call last): File "/opt/rockstor/src/rockstor/rest_framework_custom/generic_view.py", line 40, in _handle_exception yield File "/opt/rockstor/src/rockstor/storageadmin/views/nfs_exports.py", line 241, in put NFSExportGroup.objects.filter(id=export_id)[0].clean_fields(exclude="admin_host") File "/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/base.py", line 1527, in clean_fields raise ValidationError(errors) django.core.exceptions.ValidationError: {'host_str': ['Invalid host string: 192.168.1.0/24']}
1 Like

Hi @npfinnigan ,

Thanks for the detailed report. You are correct that this is indeed related to the addition of the subnet mask to the IP address. Here’s a quick rundown of the error you are seeing:

First, it is failing at the clean_fields() step, which is a base Django step used to validate the field(s) in question.

For this model, we actually use a ā€œcustomā€ validator…

… defined at:

This uses one of the validators built-in Django core (validate_ipv46_address(value)), which itself relies on the Python standard lib ipaddress to try to read that IP address as v4 and then as v6. Because of the subnet mask, the first one fails: if we try to validate an IP address with a subnet mask here, we end up indeed with a more explicit error:

Traceback (most recent call last):
  File "/opt/rockstor/.venv/lib/python3.11/site-packages/django/core/validators.py", line 276, in validate_ipv4_address
    ipaddress.IPv4Address(value)
  File "/usr/lib64/python3.11/ipaddress.py", line 1318, in __init__
    raise AddressValueError(f"Unexpected '/' in {address!r}")
ipaddress.AddressValueError: Unexpected '/' in '192.168.4.0/24'

I’m not sure when that ā€œbugā€ appeared (if it is related to a change in our version of Django used) or if it is more an issue with our tooltip bubble that is indeed mentioning the use of netmask:

<strong>IP networks:</strong> All hosts of a subnet given by <strong>address/netmask</strong>.

At first glance, I think we may need to switch to using a more appropriate validator here, one that can deal with an address/netmask format (it looks like ipaddress.ip_network() is able to do just that).

Sorry if I can’t provide a quick fix here, but I’m glad you are able to manually get what you need at least for the moment.

2 Likes

@Flox do you think this would be an additional validator, or do you think the ipaddress.ip_network will handle both types of entries? From the documentation it doesn’t seem clear to me. I suspect you would need to use both?

Thanks @Flox for investigating. I understand the issue with providing quick fixes for everything. I have simple work arounds for most of my shares.

I confirmed this bug and waiting for bugfix of this issue.

1 Like

Adhidarna,

Apologies. I have an acceptable workround now and I should have posted it here before now.

When creating the export use the ā€˜Advanced Edit’ button. Then put your export requirements in the box that is marked ā€˜Enter manual export entries below’. The box is actually just to the right on my screen but it works fine. You just need to enter exports such as:

/export/nfs 192.168.1.0/24(rw,no_root_squash)

Of course you are probably not foolish enough to use no_root_squash but just put in the export options you need. Not much better than editing /etc yourself but is is a little better.

Note using this method does not magically allow Rockstor to manage the export. My NFS service reports that " No NFS exports have been created" when I have created many. However they are easier to manage for me than if they are in /etc.

I hope that helps you as well.

3 Likes

Just wanted to link to the corresponding issue to track progress on its resolution:

2 Likes