Skip to content

mgr/dashboard: add smb endpoints - #60759

Merged
afreen23 merged 1 commit into
ceph:mainfrom
rhcs-dashboard:add-smb-endpoints
Dec 2, 2024
Merged

afreen23 merged 1 commit into
ceph:mainfrom
rhcs-dashboard:add-smb-endpoints

Conversation

@Pegonzal

Copy link
Copy Markdown
Contributor

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@Pegonzal
Pegonzal force-pushed the add-smb-endpoints branch 3 times, most recently from 0ff9717 to a4f19ef Compare November 25, 2024 18:04
@Pegonzal
Pegonzal marked this pull request as ready for review November 25, 2024 18:05
@Pegonzal
Pegonzal requested a review from a team as a code owner November 25, 2024 18:05
@Pegonzal
Pegonzal requested review from aaSharma14 and pujaoshahu and removed request for a team November 25, 2024 18:05
Comment on lines 33 to 73

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

@Pegonzal Pegonzal Nov 27, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know that ceph smb cluster commands are different but aren't we aligned with ceph smb apply ...?

@Pegonzal Pegonzal Nov 27, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread src/pybind/mgr/dashboard/security.py Resolved
@Pegonzal

Copy link
Copy Markdown
Contributor Author

Thanks @nizamial09 for the review, I answered your comments and updated the PR with:
11a8f42

please take another look, thanks!

@Pegonzal

Pegonzal commented Nov 28, 2024 •

Copy link
Copy Markdown
Contributor Author

Thanks @nizamial09 for the comments. Upated the PR again, please take a look once more

@Pegonzal Pegonzal mentioned this pull request Nov 28, 2024
4 of 14 tasks

@nizamial09 nizamial09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you so much @Pegonzal for addressing the reviews. Some suggestions below but I won't be blocking the PR on those.

Comment on lines 22 to 88

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh yeah, good catch. hmm I think that's something we need to improve on our RESTController then!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sounds good, thanks

@nizamial09

Copy link
Copy Markdown
Member

just saw, the commit says Traceback: https://tracker.ceph.com/issues/69044... Python messing with your head xDD

@Pegonzal

Copy link
Copy Markdown
Contributor Author

just saw, the commit says Traceback: https://tracker.ceph.com/issues/69044... Python messing with your head xDD

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 .
Only thing left here would be to endpoint doc to use models in favour of schemas, but leaving it to take it outside this PR

@nizamial09 nizamial09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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]>
@Pegonzal

Copy link
Copy Markdown
Contributor Author

jenkins test api

1 similar comment
@Pegonzal

Pegonzal commented Dec 1, 2024

Copy link
Copy Markdown
Contributor Author

jenkins test api

@afreen23
afreen23 merged commit 78b4fdf into ceph:main Dec 2, 2024
@afreen23
afreen23 deleted the add-smb-endpoints branch December 2, 2024 09:24
@phlogistonjohn

Copy link
Copy Markdown
Contributor

Getting back to this late, but I would be ok adding an option to always return a list something like --no-minimize etc. But since you merged already I suppose you don't need it. I'll revisit this next week and provide feedback elsewhere if needed.

@Pegonzal

Pegonzal commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

Getting back to this late, but I would be ok adding an option to always return a list something like --no-minimize etc. But since you merged already I suppose you don't need it. I'll revisit this next week and provide feedback elsewhere if needed.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants