]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: automatically enable proxy for shares with proxied provider
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 6 Sep 2024 15:54:52 +0000 (11:54 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 4 Feb 2025 19:24:20 +0000 (14:24 -0500)
Automatically enable the proxy for the smb service spec when any
share in the cluster has a proxied provider enum value.
Enable the proxy option (per-share) when the share is proxied but
disable it when just requesting the new vfs ceph module.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/handler.py

index d924d8bc85ec58be61ede36eac151b11b068fe58..f59613c113ac0594c2926cb7c10e13fbd2a80b84 100644 (file)
@@ -60,6 +60,7 @@ ShareRef = Union[resources.Share, resources.RemovedShare]
 
 _DOMAIN = 'domain'
 _CLUSTERED = 'clustered'
+_CEPHFS_PROXY = 'cephfs-proxy'
 log = logging.getLogger(__name__)
 
 
@@ -685,6 +686,7 @@ class ClusterConfigHandler:
             join_source_entries=join_source_entries,
             user_source_entries=user_source_entries,
             data_entity=data_entity,
+            needs_proxy=_has_proxied_vfs(change_group),
         )
         _save_pending_spec_backup(self.public_store, change_group, smb_spec)
         # if orch was ever needed in the past we must "re-orch", but if we have
@@ -1174,9 +1176,10 @@ def _generate_share(
         cephfs.path,
     )
     try:
-        ceph_vfs = {
-            CephFSStorageProvider.SAMBA_VFS_CLASSIC: 'ceph',
-            CephFSStorageProvider.SAMBA_VFS_NEW: 'ceph_new',
+        ceph_vfs, proxy_val = {
+            CephFSStorageProvider.SAMBA_VFS_CLASSIC: ('ceph', ''),
+            CephFSStorageProvider.SAMBA_VFS_NEW: ('ceph_new', 'no'),
+            CephFSStorageProvider.SAMBA_VFS_PROXIED: ('ceph_new', 'yes'),
         }[cephfs.provider.expand()]
     except KeyError:
         raise ValueError(f'unsupported provider: {cephfs.provider}')
@@ -1195,6 +1198,8 @@ def _generate_share(
             'x:ceph:id': f'{share.cluster_id}.{share.share_id}',
         }
     }
+    if proxy_val:
+        cfg['options'][f'{ceph_vfs}:proxy'] = proxy_val
     # extend share with user+group login access lists
     _generate_share_login_control(share, cfg)
     # extend share with custom options
@@ -1308,12 +1313,15 @@ def _generate_smb_service_spec(
     join_source_entries: List[ConfigEntry],
     user_source_entries: List[ConfigEntry],
     data_entity: str = '',
+    needs_proxy: bool = False,
 ) -> SMBSpec:
     features = []
     if cluster.auth_mode == AuthMode.ACTIVE_DIRECTORY:
         features.append(_DOMAIN)
     if cluster.is_clustered():
         features.append(_CLUSTERED)
+    if needs_proxy:
+        features.append(_CEPHFS_PROXY)
     # only one config uri can be used, the input list should be
     # ordered from lowest to highest priority and the highest priority
     # item that exists in the store will be used.
@@ -1469,3 +1477,14 @@ def _store_transaction(store: ConfigStore) -> Iterator[None]:
     log.debug("Using store transaction")
     with transaction():
         yield None
+
+
+def _has_proxied_vfs(change_group: ClusterChangeGroup) -> bool:
+    """Return true if any shares in the change group use the new vfs module
+    with the proxied cephfs library.
+    """
+    return any(
+        s.checked_cephfs.provider.expand()
+        == CephFSStorageProvider.SAMBA_VFS_PROXIED
+        for s in change_group.shares
+    )