From: Shweta Bhosale Date: Tue, 25 Mar 2025 08:19:53 +0000 (+0530) Subject: mgr/nfs: Added skip_notify_nfs_server parameter to update export commands X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c9ba6f3f3ec4d04e440bb520a28a56e813867175;p=ceph.git mgr/nfs: Added skip_notify_nfs_server parameter to update export commands fixes: https://tracker.ceph.com/issues/69458 Signed-off-by: Shweta Bhosale --- diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index d0a15b85bf63..3fba41ec109e 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -160,6 +160,7 @@ class ExportMgr: self.mgr = mgr self.rados_pool = POOL_NAME self._exports: Optional[Dict[str, List[Export]]] = export_ls + self.skip_notify_nfs_server = False @property def exports(self) -> Dict[str, List[Export]]: @@ -280,7 +281,8 @@ class ExportMgr: self._rados(cluster_id).write_obj( format_block(export.to_export_block()), export_obj_name(export.export_id), - conf_obj_name(export.cluster_id) + conf_obj_name(export.cluster_id), + (not self.skip_notify_nfs_server) ) def _delete_export( @@ -305,7 +307,8 @@ class ExportMgr: self._delete_export_user(export) if pseudo_path: self._rados(cluster_id).remove_obj( - export_obj_name(export.export_id), conf_obj_name(cluster_id)) + export_obj_name(export.export_id), conf_obj_name(cluster_id), + (not self.skip_notify_nfs_server)) self.exports[cluster_id].remove(export) if export.fsal.name == NFS_GANESHA_SUPPORTED_FSALS[1]: self._delete_export_user(export) @@ -339,7 +342,7 @@ class ExportMgr: self._rados(cluster_id).update_obj( format_block(export.to_export_block()), export_obj_name(export.export_id), conf_obj_name(export.cluster_id), - should_notify=not need_nfs_service_restart) + should_notify=(not need_nfs_service_restart and not self.skip_notify_nfs_server)) if need_nfs_service_restart: restart_nfs_service(self.mgr, export.cluster_id) diff --git a/src/pybind/mgr/nfs/module.py b/src/pybind/mgr/nfs/module.py index 8ba5bc175201..2a5b43532c74 100644 --- a/src/pybind/mgr/nfs/module.py +++ b/src/pybind/mgr/nfs/module.py @@ -46,9 +46,11 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): sectype: Optional[List[str]] = None, xprtsec: Optional[str] = None, cmount_path: Optional[str] = "/", - transports: Optional[List[str]] = None + transports: Optional[List[str]] = None, + skip_notify_nfs_server: bool = False ) -> Dict[str, Any]: """Create a CephFS export""" + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server earmark_resolver = CephFSEarmarkResolver(self) return self.export_mgr.create_export( fsal_type='cephfs', @@ -79,9 +81,11 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): squash: str = 'none', sectype: Optional[List[str]] = None, xprtsec: Optional[str] = None, - transports: Optional[List[str]] = None + transports: Optional[List[str]] = None, + skip_notify_nfs_server: bool = False ) -> Dict[str, Any]: """Create an RGW export""" + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server return self.export_mgr.create_export( fsal_type='rgw', bucket=bucket, @@ -98,14 +102,22 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): @NFSCLICommand('nfs export rm', perm='rw') @object_format.EmptyResponder() - def _cmd_nfs_export_rm(self, cluster_id: str, pseudo_path: str) -> None: + def _cmd_nfs_export_rm(self, + cluster_id: str, + pseudo_path: str, + skip_notify_nfs_server: bool = False) -> None: """Remove a cephfs export""" + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server return self.export_mgr.delete_export(cluster_id=cluster_id, pseudo_path=pseudo_path) @NFSCLICommand('nfs export delete', perm='rw') @object_format.EmptyResponder() - def _cmd_nfs_export_delete(self, cluster_id: str, pseudo_path: str) -> None: + def _cmd_nfs_export_delete(self, + cluster_id: str, + pseudo_path: str, + skip_notify_nfs_server: bool = False) -> None: """Delete a cephfs export (DEPRECATED)""" + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server return self.export_mgr.delete_export(cluster_id=cluster_id, pseudo_path=pseudo_path) @NFSCLICommand('nfs export ls', perm='r') @@ -129,9 +141,13 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): @NFSCLICommand('nfs export apply', perm='rw') @CLICheckNonemptyFileInput(desc='Export JSON or Ganesha EXPORT specification') @object_format.Responder() - def _cmd_nfs_export_apply(self, cluster_id: str, inbuf: str) -> AppliedExportResults: + def _cmd_nfs_export_apply(self, + cluster_id: str, + inbuf: str, + skip_notify_nfs_server: bool = False) -> AppliedExportResults: earmark_resolver = CephFSEarmarkResolver(self) """Create or update an export by `-i `""" + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server return self.export_mgr.apply_export(cluster_id, export_config=inbuf, earmark_resolver=earmark_resolver) @@ -256,10 +272,12 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): max_client_write_bw: str = '0', max_client_read_bw: str = '0', max_export_combined_bw: str = '0', - max_client_combined_bw: str = '0' + max_client_combined_bw: str = '0', + skip_notify_nfs_server: bool = False ) -> None: """enable QOS bandwidth control for NFS export and set different bandwidth""" try: + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server bw_obj = QOSBandwidthControl(enable_bw_ctrl=True, combined_bw_ctrl=combined_rw_bw_ctrl, export_writebw=max_export_write_bw, @@ -282,8 +300,12 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): @CLICommand('nfs export qos disable bandwidth_control', perm='rw') @object_format.EmptyResponder() - def _cmd_export_qos_bw_disable(self, cluster_id: str, pseudo_path: str) -> None: + def _cmd_export_qos_bw_disable(self, + cluster_id: str, + pseudo_path: str, + skip_notify_nfs_server: bool = False) -> None: """Disable NFS export QOS bandwidth control""" + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server return self.export_mgr.disable_export_qos_bw(cluster_id, pseudo_path) @CLICommand('nfs cluster qos enable bandwidth_control', perm='rw') @@ -333,9 +355,11 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): pseudo_path: str, max_export_iops: int = 0, max_client_iops: int = 0, + skip_notify_nfs_server: bool = False ) -> None: """enable QOS IOPS control for NFS export""" try: + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server ops_obj = QOSOpsControl(enable_iops_ctrl=True, max_export_iops=max_export_iops, max_client_iops=max_client_iops) @@ -347,8 +371,12 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): @CLICommand('nfs export qos disable ops_control', perm='rw') @object_format.EmptyResponder() - def _cmd_export_qos_ops_disable(self, cluster_id: str, pseudo_path: str) -> None: + def _cmd_export_qos_ops_disable(self, + cluster_id: str, + pseudo_path: str, + skip_notify_nfs_server: bool = False) -> None: """Disable NFS export QOS IOPS control""" + self.export_mgr.skip_notify_nfs_server = skip_notify_nfs_server return self.export_mgr.disable_export_qos_ops(cluster_id, pseudo_path) @CLICommand('nfs cluster qos enable ops_control', perm='rw') diff --git a/src/pybind/mgr/nfs/rados_utils.py b/src/pybind/mgr/nfs/rados_utils.py index 5ce699fd3ff2..0139cb7889a7 100644 --- a/src/pybind/mgr/nfs/rados_utils.py +++ b/src/pybind/mgr/nfs/rados_utils.py @@ -28,7 +28,11 @@ class NFSRados: def _create_url_block(self, obj_name: str) -> RawBlock: return RawBlock('%url', values={'value': self._make_rados_url(obj_name)}) - def write_obj(self, conf_block: str, obj: str, config_obj: str = '') -> None: + def write_obj(self, + conf_block: str, + obj: str, + config_obj: str = '', + should_notify: Optional[bool] = True) -> None: with self.rados.open_ioctx(self.pool) as ioctx: ioctx.set_namespace(self.namespace) ioctx.write_full(obj, conf_block.encode('utf-8')) @@ -41,7 +45,8 @@ class NFSRados: # Add created obj url to common config obj ioctx.append(config_obj, format_block( self._create_url_block(obj)).encode('utf-8')) - _check_rados_notify(ioctx, config_obj) + if should_notify: + _check_rados_notify(ioctx, config_obj) log.debug("Added %s url to %s", obj, config_obj) def read_obj(self, obj: str) -> Optional[str]: @@ -63,7 +68,7 @@ class NFSRados: _check_rados_notify(ioctx, config_obj) log.debug("Update export %s in %s", obj, config_obj) - def remove_obj(self, obj: str, config_obj: str) -> None: + def remove_obj(self, obj: str, config_obj: str, should_notify: Optional[bool] = True) -> None: with self.rados.open_ioctx(self.pool) as ioctx: ioctx.set_namespace(self.namespace) export_urls = ioctx.read(config_obj) @@ -71,7 +76,8 @@ class NFSRados: export_urls = export_urls.replace(url.encode('utf-8'), b'') ioctx.remove_object(obj) ioctx.write_full(config_obj, export_urls) - _check_rados_notify(ioctx, config_obj) + if should_notify: + _check_rados_notify(ioctx, config_obj) log.debug("Object deleted: %s", url) def remove_all_obj(self) -> None: