[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.
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']}
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.
@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?