]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: add coverage for virtual_ip bind_addr in nfs 66930/head
authorShubha Jain <SHUBHA.JAIN1@ibm.com>
Fri, 17 Apr 2026 11:41:10 +0000 (17:11 +0530)
committerShubha Jain <SHUBHA.JAIN1@ibm.com>
Wed, 8 Jul 2026 12:43:15 +0000 (18:13 +0530)
Signed-off-by: Shubha Jain <SHUBHA.JAIN1@ibm.com>
src/pybind/mgr/cephadm/templates/services/nfs/ganesha.conf.j2
src/pybind/mgr/cephadm/tests/services/test_nfs.py

index 768e64302f4c27217453177fac01c7debbfeeee7..1c10f2b91287f044c55d14dd82660fa959dd051c 100644 (file)
@@ -11,6 +11,9 @@ NFS_CORE_PARAM {
         Enable_UDP = false;
         NFS_Port = {{ port }};
         allow_set_io_flusher_fail = true;
+{% if haproxy_hosts %}
+        HAProxy_Hosts = {{ haproxy_hosts|join(", ") }};
+{% endif %}
 {% if monitoring_addr %}
         Monitoring_Addr = {{ monitoring_addr }};
 {% endif %}
@@ -20,9 +23,6 @@ NFS_CORE_PARAM {
 {% if bind_addr %}
         Bind_addr = {{ bind_addr }};
 {% endif %}
-{% if haproxy_hosts %}
-        HAProxy_Hosts = {{ haproxy_hosts|join(", ") }};
-{% endif %}
 {% if enable_rdma and rdma_port %}
         NFS_RDMA_Port = {{ rdma_port }};
 {% endif %}
@@ -94,5 +94,4 @@ TLS_CONFIG{
 {% endif %}
 }
 {% endif %}
-
 %url    {{ url }}
index 0094aad24f510bcc0a1fb266259b653ef01815c4..21a94f40a6154b3bfca7d7b3db40741643481a3f 100644 (file)
@@ -99,6 +99,37 @@ class TestNFS:
                 ganesha_conf = nfs_generated_conf['files']['ganesha.conf']
                 assert "Bind_addr = 1.2.3.7" 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_bind_addr_virtual_ip(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
+        _run_cephadm.side_effect = async_side_effect(('{}', '', 0))
+
+        with with_host(cephadm_module, 'host1', addr='1.2.3.7'):
+            cephadm_module.cache.update_host_networks('host1', {
+                '1.2.3.0/24': {
+                    'if0': ['1.2.3.7']
+                }
+            })
+
+            nfs_spec = NFSServiceSpec(
+                service_id="foo",
+                placement=PlacementSpec(hosts=['host1']),
+                virtual_ip='1.2.3.100',
+                enable_haproxy_protocol=False
+            )
+
+            with with_service(cephadm_module, nfs_spec, status_running=True) as _:
+                dds = wait(cephadm_module, cephadm_module.list_daemons())
+                daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(dds[0])
+
+                nfs_generated_conf, _ = service_registry.get_service('nfs').generate_config(daemon_spec)
+                ganesha_conf = nfs_generated_conf['files']['ganesha.conf']
+
+                assert "Bind_addr = 1.2.3.100" in ganesha_conf
+
     @patch("cephadm.serve.CephadmServe._run_cephadm")
     def test_ingress_without_haproxy_stats(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
         _run_cephadm.side_effect = async_side_effect(('{}', '', 0))