]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_volume_client: evict client also based on mount path
authorRamana Raja <rraja@redhat.com>
Wed, 13 Apr 2016 08:33:51 +0000 (14:03 +0530)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Jun 2016 21:20:37 +0000 (22:20 +0100)
Evict clients based on not just their auth ID, but also based on the
volume path mounted. This is needed for the Manila use-case, where
the clients using an auth ID are denied further access to a share.

Fixes: http://tracker.ceph.com/issues/15855
Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit 68714b9dda8ed6010cad6730e0ddf54b3219150d)
(cherry picked from commit aaa0e9aea9fcf2f63e73e544bd40c10a0d694408)

src/pybind/ceph_volume_client.py

index 16d32476f502ea2c93636c779447ecc58103c836..bb75e3477be77abba55efd532b28b211f9a6828a 100644 (file)
@@ -215,16 +215,22 @@ class CephFSVolumeClient(object):
         self.cluster_name = cluster_name
         self.auth_id = auth_id
 
-    def evict(self, auth_id, timeout=30):
+    def evict(self, auth_id, timeout=30, volume_path=None):
         """
-        Evict all clients using this authorization ID. Assumes that the
-        authorisation key has been revoked prior to calling this function.
+        Evict all clients based on the authorization ID and optionally based on
+        the volume path mounted.  Assumes that the authorization key has been
+        revoked prior to calling this function.
 
         This operation can throw an exception if the mon cluster is unresponsive, or
         any individual MDS daemon is unresponsive for longer than the timeout passed in.
         """
 
-        log.info("evict: {0}".format(auth_id))
+        client_spec = ["auth_name={0}".format(auth_id), ]
+        if volume_path:
+            client_spec.append("client_metadata.root={0}".
+                               format(self._get_path(volume_path)))
+
+        log.info("evict clients with {0}".format(', '.join(client_spec)))
 
         mds_map = self._rados_command("mds dump", {})
 
@@ -239,7 +245,8 @@ class CephFSVolumeClient(object):
         # the latter doesn't give us per-mds output
         threads = []
         for rank, gid in up.items():
-            thread = RankEvicter(self, ["auth_name={0}".format(auth_id)], rank, gid, mds_map, timeout)
+            thread = RankEvicter(self, client_spec, rank, gid, mds_map,
+                                 timeout)
             thread.start()
             threads.append(thread)
 
@@ -250,9 +257,9 @@ class CephFSVolumeClient(object):
 
         for t in threads:
             if not t.success:
-                msg = "Failed to evict client {0} from mds {1}/{2}: {3}".format(
-                    auth_id, t.rank, t.gid, t.exception
-                )
+                msg = ("Failed to evict client with {0} from mds {1}/{2}: {3}".
+                       format(', '.join(client_spec), t.rank, t.gid, t.exception)
+                      )
                 log.error(msg)
                 raise EvictionError(msg)