Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon/AuthMonitor: Add special syntax for cephfs #16761

Merged
merged 2 commits into from Aug 4, 2017

Conversation

fullerdj
Copy link
Contributor

@fullerdj fullerdj commented Aug 2, 2017

Add a new command, ceph auth fs, to generate and apply auth caps for
cephfs.

Syntax:

ceph auth fs <fs_name> <entity_name> (

)...

Notes:

In this case, the AuthMonitor will determine the correct osd and
mds cap syntax based on the data pools used by <fs_name>. The same
caps will be applied to all data pools regardless of the filesystem
configuration. If the write cap is enabled on any directory, the write
cap for every data pool will be obtained.

It is legal to run ceph auth fs on an entity that already has auth
caps. In this case, the new values will overwrite the old ones and the
old key will be invalidated. In this case, clients with existing
mounts will retain their old auth caps, but will be unable to mount
with old keys. Administrative care is required to unmount or fence any
old clients after auth cap updates.

Fixes: http://tracker.ceph.com/issues/20885
Signed-off-by: Douglas Fuller dfuller@redhat.com

@fullerdj fullerdj force-pushed the wip-djf-20885 branch 3 times, most recently from 0af0a30 to 1fb9547 Compare August 2, 2017 15:58
@@ -175,6 +175,12 @@ COMMAND("auth get-or-create " \
"name=caps,type=CephString,n=N,req=false", \
"add auth info for <entity> from input file, or random key if no input given, and/or any caps specified in the command", \
"auth", "rwx", "cli,rest")
COMMAND("auth fs " \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinions as to exact syntax welcome.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would be fs authorize -- feels like it's more naturally going to be used alongside all the other fs commands, even if it's implemented in authmonitor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like that syntax better, too. Is there precedent for implementing commands in the "wrong" monitor like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this to be something like fs authorize as well. And there is a precedent. The most obvious would be pg map, which is handled by the OSDMonitor.
Basically, you'll have to add an exception to Monitor::handle_command(), where it checks if (module == "mds" || module == "fs"), and add a new || prefix == "fs authorize" (or whatever ends up being the name of the command.
For correctness' sake, you'll have to keep the COMMAND's third field, which now reads auth, as auth. This is used to validate caps during Monitor::_allowed_command().

Let me know if you bump into issues, and I'll be happy to help you out.

@fullerdj fullerdj requested review from jcsp and batrick August 2, 2017 16:00
};

KeyServerData::Incremental auth_inc;
auth_inc.op = KeyServerData::AUTH_INC_ADD;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unconditional; I think this is probably what we want, but feedback is welcome.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if the entry already exists; if so, it's basically a no-op and return to the user the appropriate info we'd be returning if this was the first time the command was being run.
If we don't, given we'll be creating a new key, we'll be replacing the key, and I don't think that's what a user would expect.
Given the user isn't providing a key, I suggest checking if the entity name exists, alongside with the same set of caps. If the caps for a given entity name differ from what we are expecting, fail; otherwise, succeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I implemented that behavior.

@ceph-jenkins
Copy link
Collaborator

make check succeeded

};

KeyServerData::Incremental auth_inc;
auth_inc.op = KeyServerData::AUTH_INC_ADD;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if the entry already exists; if so, it's basically a no-op and return to the user the appropriate info we'd be returning if this was the first time the command was being run.
If we don't, given we'll be creating a new key, we'll be replacing the key, and I don't think that's what a user would expect.
Given the user isn't providing a key, I suggest checking if the entity name exists, alongside with the same set of caps. If the caps for a given entity name differ from what we are expecting, fail; otherwise, succeed.

@jecluis jecluis added the mon label Aug 2, 2017
Add a new command, ceph auth fs, to generate and apply auth caps for
cephfs.

Syntax:

  ceph auth fs <fs_name> <entity_name> (<dir> <cap>)...

Notes:

  In this case, the AuthMonitor will determine the correct osd and
  mds cap syntax based on the data pools used by <fs_name>. The same
  caps will be applied to all data pools regardless of the filesystem
  configuration. If the write cap is enabled on any directory, the write
  cap for every data pool will be obtained.

  If different auth caps for this entity already exist, the result is
  -EINVAL.

Fixes: http://tracker.ceph.com/issues/20885
Signed-off-by: Douglas Fuller <dfuller@redhat.com>

fixup
Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs and command are out of sync.

Change the CephFS auth caps documentation to reflect the new ceph auth
fs command.

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
@fullerdj
Copy link
Contributor Author

fullerdj commented Aug 4, 2017

Docs updated; this should be good to merge.

@batrick
Copy link
Member

batrick commented Aug 4, 2017

Just waiting for @liewegas to say this looks like the right approach and then I'll merge.

@liewegas
Copy link
Member

liewegas commented Aug 4, 2017

This looks fine to me. My only concern is what happens when a new data pool is added at a later date. I'm not sure if/how the existing caps can be updated given that we're not flagging the caps as "magic" ones that need to be redone later.

Maybe we could stash that information (i.e., teh original path list with r or rw) in a separate cap (cephfs-auth) that isn't being used so that the cap can be identified later. (Just brainstorming)

@batrick
Copy link
Member

batrick commented Aug 4, 2017

Okay, I think we'll merge this as-is for now to set a path forward. I agree automating the cap changes when a new data pool is added would be smart. Also, the command could allow overwriting the caps (useful for qa at least) and maybe support multifs.

@batrick batrick merged commit f249e3d into ceph:master Aug 4, 2017
batrick added a commit that referenced this pull request Aug 4, 2017
* refs/remotes/upstream/pull/16761/head:
	doc/cephfs: Document ceph auth fs
	mon/AuthMonitor: Add special syntax for cephfs

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
@fullerdj
Copy link
Contributor Author

fullerdj commented Aug 4, 2017 via email

@gregsfortytwo
Copy link
Member

Actually I don't think we want to automatically add caps when new pools go into the FS (at least, not all the time) — they're a separate authentication/authorization zone.

@liewegas
Copy link
Member

liewegas commented Aug 4, 2017 via email

@batrick
Copy link
Member

batrick commented Aug 4, 2017

Great point @gregsfortytwo. @fullerdj please make a new tracker ticket for potential enhancements to "fs authorize" to consider.

@fullerdj fullerdj deleted the wip-djf-20885 branch August 7, 2017 13:38
batrick added a commit to batrick/ceph that referenced this pull request Aug 7, 2017
Introduced by ceph#16761.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
batrick added a commit to batrick/ceph that referenced this pull request Aug 7, 2017
Introduced by ceph#16761.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants