Skip to content

Commit

Permalink
Rename rdma.capable_services to rdma.capable_protocols. (#14796)
Browse files Browse the repository at this point in the history
And added a CI test.
  • Loading branch information
mgrimesix authored Oct 28, 2024
1 parent 175a738 commit 0427588
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/middlewared/middlewared/api/v25_04_0/rdma.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = [
"RdmaLinkConfigArgs", "RdmaLinkConfigResult",
"RdmaCardConfigArgs", "RdmaCardConfigResult",
"RdmaCapableServicesArgs", "RdmaCapableServicesResult"
"RdmaCapableProtocolsArgs", "RdmaCapableProtocolsResult"
]


Expand Down Expand Up @@ -33,9 +33,9 @@ class RdmaCardConfigResult(BaseModel):
links: list[RdmaLinkConfig]


class RdmaCapableServicesArgs(BaseModel):
class RdmaCapableProtocolsArgs(BaseModel):
pass


class RdmaCapableServicesResult(BaseModel):
class RdmaCapableProtocolsResult(BaseModel):
result: list[Literal["NFS"]]
4 changes: 2 additions & 2 deletions src/middlewared/middlewared/plugins/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ async def do_update(self, data):
verrors.add("nfs_update.v4_domain", "This option does not apply to NFSv3")

if new["rdma"]:
available_rdma_services = await self.middleware.call('rdma.capable_services')
if "NFS" not in available_rdma_services:
available_rdma_protocols = await self.middleware.call('rdma.capable_protocols')
if 'NFS' not in available_rdma_protocols:
verrors.add(
"nfs_update.rdma",
"This platform cannot support NFS over RDMA or is missing an RDMA capable NIC."
Expand Down
6 changes: 3 additions & 3 deletions src/middlewared/middlewared/plugins/rdma/rdma.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from middlewared.api.current import (
RdmaLinkConfigArgs, RdmaLinkConfigResult,
RdmaCardConfigArgs, RdmaCardConfigResult,
RdmaCapableServicesArgs, RdmaCapableServicesResult
RdmaCapableProtocolsArgs, RdmaCapableProtocolsResult
)
from middlewared.service import Service, private
from middlewared.service_exception import CallError
Expand Down Expand Up @@ -126,8 +126,8 @@ def get_card_choices(self):
v['name'] = ':'.join(sorted(names))
return list(grouper.values())

@api_method(RdmaCapableServicesArgs, RdmaCapableServicesResult)
async def capable_services(self):
@api_method(RdmaCapableProtocolsArgs, RdmaCapableProtocolsResult)
async def capable_protocols(self):
result = []
is_ent = await self.middleware.call('system.is_enterprise')
if is_ent and 'MINI' not in await self.middleware.call('truenas.get_chassis_hardware'):
Expand Down
29 changes: 29 additions & 0 deletions tests/api2/test_300_nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,35 @@ def test_manage_gids(self, start_nfs, state, expected):
s = parse_server_config()
assert s['mountd']['manage-gids'] == expected, str(s)

def test_rdma_config(self, start_nfs):
'''
Mock response from rdma.capable_protocols to confirm NFS over RDMA config setting
'''
assert start_nfs is True

# Confirm the setting does not exist by default
s = parse_server_config()
assert s.get('rdma') is None, str(s)

# RDMA setting should fail on a test vm.
with pytest.raises(ValidationErrors) as ve:
call("nfs.update", {"rdma": True})
assert ve.value.errors == [
ValidationError(
'nfs_update.rdma',
'This platform cannot support NFS over RDMA or is missing an RDMA capable NIC.',
22
)
]

with mock("rdma.capable_protocols", return_value=['NFS']):
with nfs_config():
call("nfs.update", {"rdma": True})
s = parse_server_config()
assert s['nfsd']['rdma'] == 'y', str(s)
# 20049 is the default port for NFS over RDMA.
assert s['nfsd']['rdma-port'] == '20049', str(s)


def test_pool_delete_with_attached_share():
'''
Expand Down

0 comments on commit 0427588

Please sign in to comment.