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

control/state: add name to rados.Rados object initialization #166

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

adk3798
Copy link
Contributor

@adk3798 adk3798 commented Jul 27, 2023

If we want to use a keyring that isn't the client.admin keyring, we need to provide the name. The rados.Rados object defaults the name to client.admin, and if that doesn't match the provided keyring you end up hitting an error like

ERROR:control.state:Unable to create omap: [errno 13] RADOS permission denied (error connecting to the cluster). Exiting! INFO:control.server:Terminating SPDK...
INFO:control.server:Exiting the gateway process.
Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/src/control/__main__.py", line 35, in <module>
    gateway.serve()
  File "/src/control/server.py", line 99, in serve
    omap_state = OmapGatewayState(self.config)
  File "/src/control/state.py", line 178, in __init__
    conn.connect()
  File "rados.pyx", line 680, in rados.Rados.connect
rados.PermissionDeniedError: [errno 13] RADOS permission denied (error connecting to the cluster)

Setting the correct name gets around this and allows other keyrings with the correct name and permissions to be used

@adk3798
Copy link
Contributor Author

adk3798 commented Jul 27, 2023

NOTE: This is where the name is defaulted to client.admin in python librados if it is not provided. https://github.com/ceph/ceph/blob/main/src/pybind/rados/rados.pyx#L425-L426

@trociny
Copy link
Contributor

trociny commented Jul 27, 2023

Thank you for bringing this up. I am not sure though that "name" param from "gateway" section is a good choice for this. It is supposed to have different names for gateways in the same group (if "name" param is empty in the config then the hostname is used), and with your approach it would add a restriction to create a separate ceph user for every gateway. This may be not a big problem but I am not sure we want this restriction. Moreover the gateway name should be "client.XYZ" (this could be solved though by using rados_id param instead of name in your approach).

Instead of re-using the gateway name param I would prefer if we added "name" (or "id") param into "ceph" section and use it. Additionally it would be good to add "mon_host" and "keyring" (or "keyfile") params (which could be passed in "conf" arg when initializing the rados object). Then it would be possible to have setups without ceph.conf file, keeping all ceph related settings for the gateway clients in the ceph mon db.

@adk3798
Copy link
Contributor Author

adk3798 commented Jul 27, 2023

Thank you for bringing this up. I am not sure though that "name" param from "gateway" section is a good choice for this. It is supposed to have different names for gateways in the same group (if "name" param is empty in the config then the hostname is used), and with your approach it would add a restriction to create a separate ceph user for every gateway. This may be not a big problem but I am not sure we want this restriction. Moreover the gateway name should be "client.XYZ" (this could be solved though by using rados_id param instead of name in your approach).

Instead of re-using the gateway name param I would prefer if we added "name" (or "id") param into "ceph" section and use it. Additionally it would be good to add "mon_host" and "keyring" (or "keyfile") params (which could be passed in "conf" arg when initializing the rados object). Then it would be possible to have setups without ceph.conf file, keeping all ceph related settings for the gateway clients in the ceph mon db.

sure, if I want it to be something in the "ceph" section do I need to do anything special, or just change this to try and check the config for a "name" option in the "ceph" section (and probably have a default if it isn't specified)

@trociny
Copy link
Contributor

trociny commented Jul 27, 2023

sure, if I want it to be something in the "ceph" section do I need to do anything special, or just change this to try and check the config for a "name" option in the "ceph" section (and probably have a default if it isn't specified)

Yes, I would be fine with just changing self.config.get("gateway", "name") to self.config.get("ceph", "name") in your current version (and adding the new param to the example ceph-nvmeof.conf), though I would personally prefer "id" ("rados_id"), so one would need just to specify something like id = nvme instead of name = client.nvme in the config. And the empty (None) value for the default would be fine for me.

Though other people might have different thoughts...

@adk3798
Copy link
Contributor Author

adk3798 commented Jul 27, 2023

sure, if I want it to be something in the "ceph" section do I need to do anything special, or just change this to try and check the config for a "name" option in the "ceph" section (and probably have a default if it isn't specified)

Yes, I would be fine with just changing self.config.get("gateway", "name") to self.config.get("ceph", "name") in your current version (and adding the new param to the example ceph-nvmeof.conf), though I would personally prefer "id" ("rados_id"), so one would need just to specify something like id = nvme instead of name = client.nvme in the config. And the empty (None) value for the default would be fine for me.

Though other people might have different thoughts...

would the idea with id = nvme be that we add "client" to the front by default? We need this to match the name of the keyring we're using, which I expect to be formatted like "client.nvmeof." typically

@trociny
Copy link
Contributor

trociny commented Jul 27, 2023

would the idea with id = nvme be that we add "client" to the front by default? We need this to match the name of the keyring we're using, which I expect to be formatted like "client.nvmeof." typically

It is already done by the Rados python class, see the code you referred previously and how rados_id param is used there. I.e. instead of conn = rados.Rados(conffile=ceph_conf, name=name) you have in your code now you will have conn = rados.Rados(conffile=ceph_conf, rados_id=id)

@adk3798
Copy link
Contributor Author

adk3798 commented Jul 27, 2023

would the idea with id = nvme be that we add "client" to the front by default? We need this to match the name of the keyring we're using, which I expect to be formatted like "client.nvmeof." typically

It is already done by the Rados python class, see the code you referred previously and how rados_id param is used there. I.e. instead of conn = rados.Rados(conffile=ceph_conf, name=name) you have in your code now you will have conn = rados.Rados(conffile=ceph_conf, rados_id=id)

ah, I missed this. Alright, I think I understand what you mean now. I'll make the adjustments.

@adk3798 adk3798 force-pushed the rados-connect-name branch from 39d4708 to 62b414d Compare July 27, 2023 15:16
@adk3798
Copy link
Contributor Author

adk3798 commented Jul 27, 2023

would the idea with id = nvme be that we add "client" to the front by default? We need this to match the name of the keyring we're using, which I expect to be formatted like "client.nvmeof." typically

It is already done by the Rados python class, see the code you referred previously and how rados_id param is used there. I.e. instead of conn = rados.Rados(conffile=ceph_conf, name=name) you have in your code now you will have conn = rados.Rados(conffile=ceph_conf, rados_id=id)

ah, I missed this. Alright, I think I understand what you mean now. I'll make the adjustments.

now using rados_id over name

Copy link
Contributor

@trociny trociny left a comment

Choose a reason for hiding this comment

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

LGTM

control/state.py Outdated Show resolved Hide resolved
If we want to use a keyring that isn't the client.admin
keyring, we need to provide the name or rados id. The rados.Rados
object defaults the name to client.admin, and if that doesn't
match the provided keyring you end up hitting an error like

ERROR:control.state:Unable to create omap: [errno 13] RADOS permission denied (error connecting to the cluster). Exiting!
INFO:control.server:Terminating SPDK...
INFO:control.server:Exiting the gateway process.
Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/src/control/__main__.py", line 35, in <module>
    gateway.serve()
  File "/src/control/server.py", line 99, in serve
    omap_state = OmapGatewayState(self.config)
  File "/src/control/state.py", line 178, in __init__
    conn.connect()
  File "rados.pyx", line 680, in rados.Rados.connect
rados.PermissionDeniedError: [errno 13] RADOS permission denied (error connecting to the cluster)

Setting the correct name gets around this and allows other
keyrings with the correct name and permissions to be used

Signed-off-by: Adam King <[email protected]>
@adk3798 adk3798 force-pushed the rados-connect-name branch from 62b414d to 03ff595 Compare July 28, 2023 17:50
adk3798 added a commit to adk3798/ceph that referenced this pull request Jul 28, 2023
The current nvmeof image we have only works with
admin keyring. This is a placeholder commit that
points to an image with changes that should allow
the nvmeof daemon to use the keyring we generate
for it. This should be removed once a proper nvmeof
image is made with the necessary changes from
ceph/ceph-nvmeof#166
Copy link
Collaborator

@baum baum left a comment

Choose a reason for hiding this comment

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

Thank you Adam 👍 LGTM

adk3798 added a commit to adk3798/ceph that referenced this pull request Aug 2, 2023
The current nvmeof image we have only works with
admin keyring. This is a placeholder commit that
points to an image with changes that should allow
the nvmeof daemon to use the keyring we generate
for it. This should be removed once a proper nvmeof
image is made with the necessary changes from
ceph/ceph-nvmeof#166
@epuertat epuertat added the bug Something isn't working label Aug 7, 2023
@epuertat epuertat added this to the v0.0.2 milestone Aug 7, 2023
@epuertat epuertat merged commit 1467774 into ceph:devel Aug 7, 2023
@baum baum mentioned this pull request Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants