From: Redouane Kachach Date: Mon, 6 Jul 2026 10:30:37 +0000 (+0200) Subject: Merge pull request #67025 from ShwetaBhosale1/fix_issue_74492_set_nfs_default_protoco... X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9d5142ea08c0f4a71709aa410aa23b2ff2666bbe;p=ceph.git Merge pull request #67025 from ShwetaBhosale1/fix_issue_74492_set_nfs_default_protocol_as_4 mgr/cephadm: Updated NFS default protocol to v4 and v3 is enabled only when enable_nfsv3 is set in the spec Reviewed-by: Redouane Kachach Reviewed-by: Adam King --- 9d5142ea08c0f4a71709aa410aa23b2ff2666bbe diff --cc src/pybind/mgr/cephadm/tests/services/test_nfs.py index 5e8b2f61b2f,aa0c4d36720..e3555f25adc --- a/src/pybind/mgr/cephadm/tests/services/test_nfs.py +++ b/src/pybind/mgr/cephadm/tests/services/test_nfs.py @@@ -588,16 -589,33 +589,42 @@@ class TestNFS assert "nfsrdma" not in ganesha_conf assert "NFS_RDMA_Port" not in ganesha_conf + @patch("cephadm.serve.CephadmServe._run_cephadm") + @patch("cephadm.services.nfs.NFSService.fence_old_ranks", MagicMock()) + @patch("cephadm.services.nfs.NFSService.run_grace_tool", MagicMock()) + @patch("cephadm.services.nfs.NFSService.purge", MagicMock()) + @patch("cephadm.services.nfs.NFSService.create_rados_config_obj", MagicMock()) + def test_nfs_enable_nfsv3(self, _run_cephadm, cephadm_module: CephadmOrchestrator): + _run_cephadm.side_effect = async_side_effect(('{}', '', 0)) + + with with_host(cephadm_module, 'test'): + # Test with enable_nfsv3=False (default) + nfs_spec = NFSServiceSpec(service_id="foo", placement=PlacementSpec(hosts=['test'])) + with with_service(cephadm_module, nfs_spec) as _: + nfs_generated_conf, _ = service_registry.get_service('nfs').generate_config( + CephadmDaemonDeploySpec(host='test', daemon_id='foo.test.0.0', service_name=nfs_spec.service_name())) + ganesha_conf = nfs_generated_conf['files']['ganesha.conf'] + assert "Protocols = 4;" in ganesha_conf + + # Test with enable_nfsv3=True + nfs_spec = NFSServiceSpec(service_id="foo", placement=PlacementSpec(hosts=['test']), + enable_nfsv3=True) + with with_service(cephadm_module, nfs_spec) as _: + nfs_generated_conf, _ = service_registry.get_service('nfs').generate_config( + CephadmDaemonDeploySpec(host='test', daemon_id='foo.test.0.0', service_name=nfs_spec.service_name())) + ganesha_conf = nfs_generated_conf['files']['ganesha.conf'] + assert "Protocols = 3, 4;" in ganesha_conf + +def test_nfs_placement_count_per_host_rejected(): + spec = NFSServiceSpec( + service_id='mynfs', + placement=PlacementSpec(hosts=['h1'], count_per_host=1), + ) + with pytest.raises(SpecValidationError, match="count_per_host.*not supported"): + spec.validate() + + def test_nfs_colocation_ports_validation(): """Test validation of colocation_ports in NFSServiceSpec""" # Valid case: correct number of colocation_ports (count=3, need 2 additional)