Repository navigation
mgr/dashboard: add smb endpoints - #60759
Conversation
0ff9717 to
a4f19ef
Compare
There was a problem hiding this comment.
can't we simply input a json obj to this function that has all the values and then simply pass it over to the smb module? I would imagine smb module already has the logic for processing or validating all the spec files so we wouldn't try to duplicate it. We can look for exceptions raised by the module and try to catch it at the API?
That would, I imagine, heavily simplies this logic
There was a problem hiding this comment.
You are right @nizamial09, maybe I went over the top with this... But let me explain why:
I though it would be easier for the user to work with the fields or query params than an opaque json object where you would need to make us of "resources" structures, so the current implementation tries to abstract the "resource" entity that uses the smb mgr module.
So, for the current implementation you can use a json like:
{
"cluster_id": "rhumba",
"auth_mode": "user",
"user_group_settings": [ "ug1" ]
}
We could do as you suggested of course, and simply input a json obj:
def create(
self,
cluster_data: Dict
) -> results.Simplified:
return mgr.remote('smb', 'apply_resources', json.dumps(cluster_data)).to_simplified()
But for it to work we would need something like:
{
"cluster_data": {
"resource_type": "ceph.smb.cluster",
"cluster_id": "rhumba",
"auth_mode": "user",
"user_group_settings": [
{
"source_type": "resource",
"ref": "ug1"
}
]
}
I though there was no need to request the resource_type , source_type fields, etc... So this implementation tries to abstract that.
So if we don't want to abstract anything I suppose that's okay, but I personally don't like the idea of having actions as "cluster create" in this case have to deal with resources.
What do you think @nizamial09?
There was a problem hiding this comment.
I'd prefer simplicity here and probably for a request that is aligned with the CLI. So I think having the same json won't be too bad. It'd be future proof as well since we don't need to adapt a lot of whatever change CLI is making to it. Also, this is what we already do on the osd and service creation. UI has many fields which later generates a json and send it to backend. So I think we can start there, and also in the EndpointDoc we can mention the format of the req. If needed, later on we can see whatever customization we need. WDYT?
There was a problem hiding this comment.
for a request that is aligned with the CLI
I get that, since that's what we usually do in the Dashboard but, this is not aligned with the CLI either. The CLI cmd does not deal with resources either, CLI asks for domain_join_user_pass/define_user_pass which is a string in the form <username>%<password> instead of user_group_settings/domain_settings which are resource objects.
Source: https://docs.ceph.com/en/latest/mgr/smb/#create-cluster
So I think having the same json won't be too bad.
So yes, we will have the same available json which I agree it's okay, but this is not the behaviour of the smb cluster cmds as said before.
and also in the EndpointDoc we can mention the format of the req.
Yes, that's a good point I'll update that
If needed, later on we can see whatever customization we need. WDYT?
As usually, it will be harder to come back to this and make changes so I would prefer not having to itarate over it if really needed tbh. I also think we could also give both options to avoid having to deal with resources and this option to just send the json data.
But since it's okay with me to start with the json param only
There was a problem hiding this comment.
I know that ceph smb cluster commands are different but aren't we aligned with ceph smb apply ...?
There was a problem hiding this comment.
Yes, we are. But ceph smb apply itself is aligned with a file uploader approach (not sure if that's the best way to put it) as you expect the user to do ceph smb apply -i data.json and have all the resources they need to apply in the data.json file. So you are using a declarative approach to apply your resources.
Where as creating different endpoints for list/create/delete... is more of a imperative approach where we are explicitly stating that we want to create a cluster, or delete a cluster, this endpoints follow the imperative approach of the ceph smb cluster create cmds, that's why mentioned it before.
For example, if we wanted to just follow the ceph smb apply declarative approach in the UI we would only need a file uploader, as everything could be taken care of from this uploaded JSON instead of needing a create button, a delete button, etc...
There was a problem hiding this comment.
I think we have to chose one thing and stick with it because you were doing an imperative design for the API but in the end consumes the declarative apply_resources method. I think the extra logic that you put there is to mostly to adapt what we are getting according to that function call isn't it? If we want to make it like ceph smb cluster create then why not consume the corresponding function where that might have all these logic in the first place? Otherwise mixing them both wouldn't make much sense to me tbh. Since we prefer the declarative approach for the smb, I guess let's just follow that and get the whole thing in a json object and simplify this.
|
Thanks @nizamial09 for the review, I answered your comments and updated the PR with: please take another look, thanks! |
11a8f42 to
23c73e6
Compare
|
Thanks @nizamial09 for the comments. Upated the PR again, please take a look once more |
nizamial09
left a comment
There was a problem hiding this comment.
Thank you so much @Pegonzal for addressing the reviews. Some suggestions below but I won't be blocking the PR on those.
There was a problem hiding this comment.
instead of schema's, shall we go for models? We have already started doing that since the nvmeof and some other APIs. And it'd make sense to do it for all other newer ones that we deliver. It'd make things a bit more cleaner IMO.
There was a problem hiding this comment.
Oh okay, that makes sense, did not like schemas that much but, I'm seeing one big difference with the models, the schema provides field explanation which the models do not, also schemas show up on the swagger where as models do not:
screen-capture.13.webm
I personally find it helpful having the return objects and field descriptions in the swagger
There was a problem hiding this comment.
oh yeah, good catch. hmm I think that's something we need to improve on our RESTController then!
There was a problem hiding this comment.
Okay, then for now I'll leave it as it is, and will look into this for following PRs.
Ideally we move this schemas to their own models/smb.py and have them as NamedTuple instead of python objects
|
just saw, the commit says |
23c73e6 to
898f32c
Compare
Oh, thanks for pointing it out... it actually took me a solid minute to see what was wrong with the commit even after you saying it lol Updated the PR one last time, hopefully should be good to go know @nizamial09 . |
nizamial09
left a comment
There was a problem hiding this comment.
LGTM again! great work @Pegonzal
Adds following SMB endpoints: - cluster: list, get, create - share: list, delete Fixes: https://tracker.ceph.com/issues/69044 Signed-off-by: Pedro Gonzalez Gomez <[email protected]>
898f32c to
98d61fa
Compare
|
jenkins test api |
1 similar comment
|
jenkins test api |
|
Getting back to this late, but I would be ok adding an option to always return a list something like |
Thanks for the suggestion @phlogistonjohn, and sorry for getting this in before your feedback, I saw you were away at Cephalocon, hopefully it went grate. I'll be iterating over this so feel free to follow up with any other suggestions/comments and I'll address them in my next PR. Thank you! |
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e