Skip to content

Commit 849fbd1

Browse files
Merge pull request ceph#41779 from rishabh-d-dave/fs-auth-subcmd
mon,osd,mds: allow fs authorize to update caps Reviewed-by: Radosław Zarzyński <[email protected]> Reviewed-by: Venky Shankar <[email protected]>
2 parents f4c5809 + c9058dc commit 849fbd1

File tree

14 files changed

+774
-35
lines changed

14 files changed

+774
-35
lines changed

PendingReleaseNotes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@
190190
than the number mentioned against the config tunable `mds_max_snaps_per_dir`
191191
so that a new snapshot can be created and retained during the next schedule
192192
run.
193+
* cephfs: Running the command "ceph fs authorize" for an existing entity now
194+
upgrades the entity's capabilities instead of printing an error. It can now
195+
also change read/write permissions in a capability that the entity already
196+
holds. If the capability passed by user is same as one of the capabilities
197+
that the entity already holds, idempotency is maintained.
193198

194199
>=17.2.1
195200

doc/cephfs/client-auth.rst

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,121 @@ Following is an example of enabling root_squash in a filesystem except within
259259
caps mds = "allow rw fsname=a root_squash, allow rw fsname=a path=/volumes"
260260
caps mon = "allow r fsname=a"
261261
caps osd = "allow rw tag cephfs data=a"
262+
263+
Updating Capabilities using ``fs authorize``
264+
============================================
265+
After Ceph's Reef version, ``fs authorize`` can not only be used to create a
266+
new client with caps for a CephFS but it can also be used to add new caps
267+
(for a another CephFS or another path in same FS) to an already existing
268+
client.
269+
270+
Let's say we run following and create a new client::
271+
272+
$ ceph fs authorize a client.x / rw
273+
[client.x]
274+
key = AQAOtSVk9WWtIhAAJ3gSpsjwfIQ0gQ6vfSx/0w==
275+
$ ceph auth get client.x
276+
[client.x]
277+
key = AQAOtSVk9WWtIhAAJ3gSpsjwfIQ0gQ6vfSx/0w==
278+
caps mds = "allow rw fsname=a"
279+
caps mon = "allow r fsname=a"
280+
caps osd = "allow rw tag cephfs data=a"
281+
282+
Previously, running ``fs authorize a client.x / rw`` a second time used to
283+
print an error message. But after Reef, it instead prints message that
284+
there's not update::
285+
286+
$ ./bin/ceph fs authorize a client.x / rw
287+
no update for caps of client.x
288+
289+
Adding New Caps Using ``fs authorize``
290+
--------------------------------------
291+
Users can now add caps for another path in same CephFS::
292+
293+
$ ceph fs authorize a client.x /dir1 rw
294+
updated caps for client.x
295+
$ ceph auth get client.x
296+
[client.x]
297+
key = AQAOtSVk9WWtIhAAJ3gSpsjwfIQ0gQ6vfSx/0w==
298+
caps mds = "allow r fsname=a, allow rw fsname=a path=some/dir"
299+
caps mon = "allow r fsname=a"
300+
caps osd = "allow rw tag cephfs data=a"
301+
302+
And even add caps for another CephFS on Ceph cluster::
303+
304+
$ ceph fs authorize b client.x / rw
305+
updated caps for client.x
306+
$ ceph auth get client.x
307+
[client.x]
308+
key = AQD6tiVk0uJdARAABMaQuLRotxTi3Qdj47FkBA==
309+
caps mds = "allow rw fsname=a, allow rw fsname=b"
310+
caps mon = "allow r fsname=a, allow r fsname=b"
311+
caps osd = "allow rw tag cephfs data=a, allow rw tag cephfs data=b"
312+
313+
Changing rw permissions in caps
314+
-------------------------------
315+
316+
It's not possible to modify caps by running ``fs authorize`` except for the
317+
case when read/write permissions have to be changed. This so because the
318+
``fs authorize`` becomes ambiguous. For example, user runs ``fs authorize
319+
cephfs1 /dir1 client.x rw`` to create a client and then runs ``fs authorize
320+
cephfs1 /dir2 client.x rw`` (notice ``/dir1`` is changed to ``/dir2``).
321+
Running second command can be interpreted as changing ``/dir1`` to ``/dir2``
322+
in current cap or can also be interpreted as authorizing the client with a
323+
new cap for path ``/dir2``. As seen in previous sections, second
324+
interpretation is chosen and therefore it's impossible to update a part of
325+
capability granted except rw permissions. Following is how read/write
326+
permissions for ``client.x`` (that was created above) can be changed::
327+
328+
$ ceph fs authorize a client.x / r
329+
[client.x]
330+
key = AQBBKjBkIFhBDBAA6q5PmDDWaZtYjd+jafeVUQ==
331+
$ ceph auth get client.x
332+
[client.x]
333+
key = AQBBKjBkIFhBDBAA6q5PmDDWaZtYjd+jafeVUQ==
334+
caps mds = "allow r fsname=a"
335+
caps mon = "allow r fsname=a"
336+
caps osd = "allow r tag cephfs data=a"
337+
338+
``fs authorize`` never deducts any part of caps
339+
-----------------------------------------------
340+
It's not possible to remove caps issued to a client by running ``fs
341+
authorize`` again. For example, if a client cap has ``root_squash`` applied
342+
on a certain CephFS, running ``fs authorize`` again for the same CephFS but
343+
without ``root_squash`` will not lead to any update, the client caps will
344+
remain unchanged::
345+
346+
$ ceph fs authorize a client.x / rw root_squash
347+
[client.x]
348+
key = AQD61CVkcA1QCRAAd0XYqPbHvcc+lpUAuc6Vcw==
349+
$ ceph auth get client.x
350+
[client.x]
351+
key = AQD61CVkcA1QCRAAd0XYqPbHvcc+lpUAuc6Vcw==
352+
caps mds = "allow rw fsname=a root_squash"
353+
caps mon = "allow r fsname=a"
354+
caps osd = "allow rw tag cephfs data=a"
355+
$ ceph fs authorize a client.x / rw
356+
[client.x]
357+
key = AQD61CVkcA1QCRAAd0XYqPbHvcc+lpUAuc6Vcw==
358+
no update was performed for caps of client.x. caps of client.x remains unchanged.
359+
360+
And if a client already has a caps for FS name ``a`` and path ``dir1``,
361+
running ``fs authorize`` again for FS name ``a`` but path ``dir2``, instead
362+
of modifying the caps client already holds, a new cap for ``dir2`` will be
363+
granted::
364+
365+
$ ceph fs authorize a client.x /dir1 rw
366+
$ ceph auth get client.x
367+
[client.x]
368+
key = AQC1tyVknMt+JxAAp0pVnbZGbSr/nJrmkMNKqA==
369+
caps mds = "allow rw fsname=a path=/dir1"
370+
caps mon = "allow r fsname=a"
371+
caps osd = "allow rw tag cephfs data=a"
372+
$ ceph fs authorize a client.x /dir2 rw
373+
updated caps for client.x
374+
$ ceph auth get client.x
375+
[client.x]
376+
key = AQC1tyVknMt+JxAAp0pVnbZGbSr/nJrmkMNKqA==
377+
caps mds = "allow rw fsname=a path=dir1, allow rw fsname=a path=dir2"
378+
caps mon = "allow r fsname=a"
379+
caps osd = "allow rw tag cephfs data=a"

doc/man/8/ceph.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,16 @@ Usage::
368368

369369
ceph fs add_data_pool <fs-name> <pool name/id>
370370

371-
Subcommand ``authorize`` creates a new client that will be authorized for the
372-
given path in ``<fs_name>``. Pass ``/`` to authorize for the entire FS.
373-
``<perms>`` below can be ``r``, ``rw`` or ``rwp``.
371+
Subcommand ``authorize`` creates a new client (if the client doesn't exists
372+
on the cluster) that will be authorized for the given path in ``<fs_name>``.
373+
Pass ``/`` to authorize for the entire FS. ``<perms>`` below can be ``r``,
374+
``rw`` or ``rwp``.
375+
376+
Running it for an existing client can grant the client a new capability
377+
(capability for a different CephFS on the same cluster or for a different
378+
path on the same CephFS). Or it can also change read/write permission in the
379+
capability that client already holds.
380+
374381

375382
Usage::
376383

qa/tasks/cephfs/cephfs_test_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,4 @@ def create_client(self, client_id, moncap=None, osdcap=None, mdscap=None):
425425
cmd += ['mds', mdscap]
426426

427427
self.run_ceph_cmd(*cmd)
428-
return self.run_ceph_cmd(f'auth get {self.client_name}')
428+
return self.get_ceph_cmd_stdout(f'auth get {self.client_name}')

0 commit comments

Comments
 (0)