From c5ccbf1108532547f54f084b8f06c7f5ddf8a4e8 Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Sun, 24 Sep 2017 20:23:12 +0530 Subject: [PATCH] ceph_volume_client: fix setting caps for IDs ... 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 (cherry picked from commit baf3b88800c63ef7467abbc7b54e40c0da669f38) --- qa/tasks/cephfs/test_volume_client.py | 39 +++++++++++++++++++++++++++ src/pybind/ceph_volume_client.py | 3 +++ 2 files changed, 42 insertions(+) diff --git a/qa/tasks/cephfs/test_volume_client.py b/qa/tasks/cephfs/test_volume_client.py index faccdff0be18a..0876af96efe0b 100644 --- a/qa/tasks/cephfs/test_volume_client.py +++ b/qa/tasks/cephfs/test_volume_client.py @@ -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) diff --git a/src/pybind/ceph_volume_client.py b/src/pybind/ceph_volume_client.py index 9d36409baff18..c14eadb2ded54 100644 --- a/src/pybind/ceph_volume_client.py +++ b/src/pybind/ceph_volume_client.py @@ -1066,6 +1066,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) -- 2.39.5