Skip to content

mgr: add a new smb cluster & share module - #56350

Merged
adk3798 merged 36 commits into
ceph:mainfrom
phlogistonjohn:jjm-mgr-smb-module
Apr 30, 2024
Merged

adk3798 merged 36 commits into
ceph:mainfrom
phlogistonjohn:jjm-mgr-smb-module

Conversation

@phlogistonjohn

@phlogistonjohn phlogistonjohn commented Mar 20, 2024 •

Copy link
Copy Markdown
Contributor

Depends on #55068
Depends on #56274

This PR adds the core of a new smb manager module. The module is inspired by the nfs module as well as prior work in cephadm, samba, the samba-operator for kubernetes and others. It builds upon and currently requires cephadm to orchestrate smb services using samba containers.

This preliminary version is missing a few obvious features but the fundamentals are largely there. You can create and remove "clusters" (currently only single smbd instances) like nfs. You can create and remove "shares" like the nfs module's "exports". AD-compatibility is already present in this version, albeit without a lot of configuration options - so it may not suite all domains exactly yet.

CLI Interface

There are two ways interacting with the smb module using the ceph CLI
command. The traditional mode uses commands like:

  ceph smb cluster create foo active-directory --domain-realm=foo.example.org --domain-join-user-pass=Administrator%Passw0rd
  ceph smb share create foo myshare1 --share-name='My Favorite Share' --cephfs-volume=cephfs --path=/my/stuff

and

  ceph smb share rm foo myshare1

The alternative is to use the ceph smb apply command to ingest configuration
resources that use a declarative style. This is inspired by the ceph orch
workflow and ceph nfs export apply. Example:

  ceph smb apply -i - <<EOF
  ---
  resource_type: ceph.smb.cluster
  cluster_id: foo
  auth_mode: active-directory
  domain_settings:
    realm: foo.example.com
    join_sources:
      - source_type: password
        auth:
          username: Administrator
          password: Passw0rd
  ---
  resource_type: ceph.smb.share
  cluster_id: foo
  share_id: myshare1
  cephfs:
    volume: cephfs
    path: /my/stuff
  EOF

To remove resources using the apply command, set the intent value to 'removed'.

  ceph smb apply -i - <<EOF
  ---
  resource_type: ceph.smb.share
  intent: removed
  cluster_id: foo
  share_id: myshare1
  EOF

Declarative mode

There are four resource types:

  • ceph.smb.cluster
  • ceph.smb.share
  • ceph.smb.join.auth
  • ceph.smb.usersgroups

The ceph.smb.cluster resource type defines properties that impact an entire
cluster, even if that's a cluster of one node. This includes what domain the
cluster might belong to.

The ceph.smb.share resource type defines properites of a single SMB share. A
share is always part of one cluster. A share's id is a short unique string. A
share's name is the string that is shared with clients. If a share name is not
explicitly defined the share's name is the same as the share's id. Shares
expose part of a cephfs file system. A share must always spcecify what cephfs
volume and path to use. Optionally, the share can refer to a subvolume (and/or
subvolumegroup) by name instead of figuring out that path first. A example YAML
block looks a bit something like this:

resource_type: ceph.smb.share
cluster_id: clustera
share_id: pictures
name: "Staff Photo Album"
cephfs:
  volume: cephfs
  path: /pictures
  subvolumegroup: userdata
  subvolume: employees

As a shortcut, in both the YAML and on the command lines a subvolume y
belonging to a subvolumegroup x can be specified as x/y using the
subvolume: field or --subvolume= cli option.

The ceph.smb.join.auth resource type contains user information needed to
join an Active Directory domain. This information can be specified inside the
cluster resource or as a ceph.smb.join.auth to seperate the two items.
The values provided to the join auth must be a username and password for
a user with sufficient rights to join a system to an AD domain.
It is recommended to create a user on the domain with the minimal rights needed
for this purpose alone.

The ceph.smb.usersgroups resource defines users and groups that wil be
set up within the cluster when using a standalone (not joined to AD) cluster.
This information can be kept separate from the cluster for easier modification
and sharing the same users with multiple clusters.

Resources can be viewed with ceph smb show. The show subcommand can be
provided with resource type as in ceph smb show ceph.smb.share or resource
type plus id strings in the form <resource_type>.<id1>[.<id2>].

NOTES

  • The cluster is not sent to cephadm for orchestration until at least one share
    is defined. The short version is that the cluster needs extra information
    about the volume and we don't know what volume to use until we have at least
    one share. If this proves to be too confusing or a big issue we can probably
    figure out a workaround if needed.

Critical TODOs prior to leaving 'draft':

  • Increase unit test coverage
  • Add teuthology tests
  • Test against some more realistic AD domains
  • Initial documentation

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, sorta
    • 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

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@phlogistonjohn
phlogistonjohn force-pushed the jjm-mgr-smb-module branch 3 times, most recently from d9c1dc4 to 62ef110 Compare April 5, 2024 19:05
@phlogistonjohn
phlogistonjohn force-pushed the jjm-mgr-smb-module branch 2 times, most recently from 2959497 to aa2f86e Compare April 6, 2024 21:15
@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

https://pulpito.ceph.com/phlogistonjohn-2024-04-08_19:15:43-orch:cephadm-wip-phlogistonjohn-testing-2024-04-06-1715-distro-default-smithi/

Lots of red, but nearly all of those are 'x in cluster log' type stuff and some timeouts. I don't see any smb related regressions and the new tests pass. No news is good news.

@phlogistonjohn
phlogistonjohn force-pushed the jjm-mgr-smb-module branch 2 times, most recently from e04a211 to defa46b Compare April 10, 2024 15:00
@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

Update: I found that the implementation regarding user-and-groups definitions was incomplete and needed changes to cephadm too. Now, the PR isn't purely adding just the smb module. JFYI

@adk3798 adk3798 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

High level review without much SMB knowledge. Also, only reviewed up to the pybind/mgr/smb: extend module.py with real smb mgmt methods commit, with the exception of the docs commit, as the rest seemed to all be unit tests or temporary xxx commits. Generally it seems good, although it can be a bit confusing trying to understand some of what's happening in resourcelib, probably because it's primarily doing type handling and is therefore very abstract (I think you may have also mentioned that would be one of the more complicated pieces to review before).

Comment thread doc/mgr/smb.rst Resolved
Comment thread doc/mgr/smb.rst Resolved
Comment thread doc/mgr/smb.rst Resolved
Comment thread doc/mgr/smb.rst Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this allowing users to specify where in the config-key store the user credentials would be stored? I assume we'd want to at least limit that to some mgr/smb/... path to be in line with how other modules use the config-key store

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.

The non-AD deployment mode has a ceph administrator defining users and groups. These are roughly the same as the ceph.smb.usersgroups resource. When we need to deliver this config to the actual smb containers we will store the generated JSON in the priv store and then the URI values for each one will be added to the user_sources list. I suppose it ought to be called user_group_sources but I guess I was being lazy. Do you think I ought to change it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no, I don't think the naming was the problem for me here. I think we talked about this offline and you said this was mostly going to be filled in by the SMB module to tell the orchestrator where it stored these credentials so that can be passed on to the SMB daemons. When I first read this I thought the expectation was for users to go and place some auth info at some arbitrary path in the config-key store or some rados object and then just pass that to the orchestrator themselves. But that doesn't seem to be the intended workflow.

Comment thread src/pybind/mgr/smb/resourcelib.py Resolved
Comment thread src/pybind/mgr/smb/handler.py Resolved
Comment thread src/pybind/mgr/smb/handler.py Resolved
Comment thread src/pybind/mgr/smb/handler.py Resolved
Comment thread src/pybind/mgr/smb/module.py Resolved
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Provide tox envs that check or reformat code with black and isort,
currently applied to only the new smb module.
This is similar to what we recently did for enabling tox in the
cephadmlib dir as it only applies to new code. However, other modules
that want to opt-in to automated, python-community-wide typical,
stop-thinking-and-let-tools-do-it approach to code formatting can
be added to the new envs later on.

Signed-off-by: John Mulligan <[email protected]>
The only distro ceph squid+ is building for at the moment that does not
already have a python version that includes dataclasses is centos/rhel
8. Add a dependency for the backport package on rhel8.

Signed-off-by: John Mulligan <[email protected]>
Add initial documentation for the new smb mgr module. It doesn't cover
every possible thing or expected future changes but it should cover
the basics of interacting with the module from the cli.

Signed-off-by: John Mulligan <[email protected]>
Add a wait_for_service_not_present task function that will wait until a
given service name is not present in the list of running cephadm
services. This is intended for testing service cleanup operations.

Signed-off-by: John Mulligan <[email protected]>
@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

I was able to get a clean run of the smb teuthology tests under orch (and only those):
https://pulpito.ceph.com/phlogistonjohn-2024-04-26_14:12:57-orch:cephadm-wip-phlogistonjohn-testing-2024-04-25-1915-distro-default-smithi/

Next step is to do a small regression run of orch/cephadm and if that goes well I think I'll move this PR out of draft.

@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

Some failures and 3 dead jobs. Most failures are 'cluster log' scrape things.
https://pulpito.ceph.com/phlogistonjohn-2024-04-26_15:06:39-orch:cephadm-wip-phlogistonjohn-testing-2024-04-25-1915-distro-default-smithi/

I don't think any of these are related to the patches, but feedback welcome (esp. @adk3798 ) in case I overlooked something.

@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

jenkins test api

@adk3798

adk3798 commented Apr 29, 2024

Copy link
Copy Markdown
Contributor

Some failures and 3 dead jobs. Most failures are 'cluster log' scrape things. https://pulpito.ceph.com/phlogistonjohn-2024-04-26_15:06:39-orch:cephadm-wip-phlogistonjohn-testing-2024-04-25-1915-distro-default-smithi/

I don't think any of these are related to the patches, but feedback welcome (esp. @adk3798 ) in case I overlooked something.

run looks okay. I recognize all the types of failures from other recent runs

@adk3798

adk3798 commented Apr 29, 2024

Copy link
Copy Markdown
Contributor

jenkins test make check

@phlogistonjohn
phlogistonjohn marked this pull request as ready for review April 30, 2024 15:11
@phlogistonjohn
phlogistonjohn requested review from a team as code owners April 30, 2024 15:11
@phlogistonjohn

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@adk3798
adk3798 merged commit 05121d1 into ceph:main Apr 30, 2024
@phlogistonjohn
phlogistonjohn deleted the jjm-mgr-smb-module branch April 30, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants