]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph_volume_client: fix setting caps for IDs
authorRamana Raja <rraja@redhat.com>
Sun, 24 Sep 2017 14:53:12 +0000 (20:23 +0530)
committerRamana Raja <rraja@redhat.com>
Fri, 29 Sep 2017 11:36:05 +0000 (17:06 +0530)
... that have empty OSD and MDS caps. Don't add a ',' at the
start of OSD and MDS caps.

Fixes: http://tracker.ceph.com/issues/21501
Signed-off-by: Ramana Raja <rraja@redhat.com>
qa/tasks/cephfs/test_volume_client.py
src/pybind/ceph_volume_client.py

index faccdff0be18a42c36e17ed00117ad5de5f29f61..0876af96efe0b985aabeda3abeb2afeb2279ad4c 100644 (file)
@@ -975,3 +975,42 @@ vc.disconnect()
             pool_name = pool_name,
             obj_name = obj_name,
         )))
+
+    def test_21501(self):
+        """
+        Reproducer for #21501 "ceph_volume_client: sets invalid caps for
+        existing IDs with no caps" (http://tracker.ceph.com/issues/21501)
+        """
+
+        vc_mount = self.mounts[1]
+        vc_mount.umount_wait()
+
+        # Configure vc_mount as the handle for driving volumeclient
+        self._configure_vc_auth(vc_mount, "manila")
+
+        # Create a volume
+        group_id = "grpid"
+        volume_id = "volid"
+        mount_path = self._volume_client_python(vc_mount, dedent("""
+            vp = VolumePath("{group_id}", "{volume_id}")
+            create_result = vc.create_volume(vp, 1024*1024*10)
+            print create_result['mount_path']
+        """.format(
+            group_id=group_id,
+            volume_id=volume_id
+        )))
+
+        # Create an auth ID with no caps
+        guest_id = '21501'
+        self.fs.mon_manager.raw_cluster_cmd_result(
+            'auth', 'get-or-create', 'client.{0}'.format(guest_id))
+
+        guest_mount = self.mounts[2]
+        guest_mount.umount_wait()
+
+        # Set auth caps for the auth ID using the volumeclient
+        self._configure_guest_auth(vc_mount, guest_mount, guest_id, mount_path)
+
+        # Mount the volume in the guest using the auth ID to assert that the
+        # auth caps are valid
+        guest_mount.mount(mount_path=mount_path)
index fecdf7562561de8e4e4b6c806664fb1a7fbd77f6..ac01807b69362a3b4c927e1d021b165ecf6b529b 100644 (file)
@@ -1065,6 +1065,9 @@ class CephFSVolumeClient(object):
                 # occurrence of wanted auth caps and no occurrence of
                 # conflicting auth caps.
 
+                if not orig:
+                    return want
+
                 cap_tokens = set(orig.split(","))
 
                 cap_tokens.discard(unwanted)