Skip to content

mgr/nfs: NFS commands to enable, disable and get QOS config for cluster and export - #61283

Closed
ShwetaBhosale1 wants to merge 1 commit into
ceph:mainfrom
ShwetaBhosale1:fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export
Closed

ShwetaBhosale1 wants to merge 1 commit into
ceph:mainfrom
ShwetaBhosale1:fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export

Conversation

@ShwetaBhosale1

@ShwetaBhosale1 ShwetaBhosale1 commented Jan 9, 2025 •

Copy link
Copy Markdown
Contributor

NFS commands to enable, disable and get QOS ratelimiting config for cluster and export

fixes: https://tracker.ceph.com/issues/69458
Signed-off-by: Shweta Bhosale [email protected]

Cluster commands:
The cluster level QOS config will get store in RADOS object 'qosconf-nfs' in cluster namespace. And this object URL will be added in 'conf-nfs'. At the time of NFS cluster creation, the qos block will not present, It will get added when the qos enabled command is run for first time. Enable and disable commands will restart NFS cluster.

Below is the example of qos block:
when enabled

QOS_DEFAULT_CONFIG {
    enable_qos = true;
    enable_bw_control = true;
    combined_rw_bw_control = false;
    qos_type = 1;
    max_export_write_bw = 10000;
    max_export_read_bw = 20000;
}

when disabled

QOS_DEFAULT_CONFIG {
    enable_qos = false;
    enable_bw_control = false;
    combined_rw_bw_control = false;
}

For enable command:
1. If combined bandwith control is disabled
a. If qos_type is pershare, then export_writebw and export_readbw parameters are compulsory
b. If qos_type is perclient, then client_writebw and client_readbw parameters are compulsory
c. If qos_type is pershare_perclient then export_writebw, export_readbw, client_writebw and
client_readbw are compulsory parameters
2. If combined bandwidth control is enabled
a. If qos_type is pershare, then export_rw_bw parameter is compulsory
b. If qos_type is perclient, then client_rw_bw parameter is compulsory
c. If qos_type is pershare_perclient, then export_rw_bw and client_rw_bw parameters are compulsory

we are accepting bandwidths in human readable format and storing after converting to bytes. Also for qos_type, we are accepting string, but storing as int. Get qos will show human readable format.

  1. To enable qos ratelimiting
    nfs cluster qos enable bandwidth_control <cluster_id> <qos_type:PerShare|PerClient|PerShare_PerClient> [--combined-rw-bw-ctrl] [--max_export_write_bw ] [--max_export_read_bw ] [--max_client_write_bw ] [--max_client_read_bw ] [--max_export_combined_bw ] [--max_client_combined_bw ] [--format ]
  2. To disable qos
    nfs cluster qos disable bandwidth_control <cluster_id>
  3. To get qos config
    nfs cluster qos get <cluster_id> [--format ]

Export commands
When export is created, there will be no QOS block, it will get added when qos enable command is run for first time. This will add QOS block in existing RADOS object for export.
Below is the example of export block when qos block is present
When enabled

EXPORT {
    FSAL {
        name = "CEPH";
        user_id = "nfs.testnfs1.testfs.df10c343";
        filesystem = "testfs";
        secret_access_key = "AQAh1JlnyHmwExAAXyH1IqQMGji1JIBVoXinbA==";
        cmount_path = "/";
    }
    QOS_BLOCK {
        enable_qos = true;
        enable_bw_control = true;
        combined_rw_bw_control = false;
        max_export_write_bw = 10000;
        max_export_read_bw = 10000;
    }
    export_id = 1;
    path = "/";
    pseudo = "/export1";
    access_type = "RW";
    squash = "none";
    attr_expiration_time = 0;
    security_label = true;
    protocols = 3, 4;
    transports = "TCP";
}

when disabled

    QOS_BLOCK {
        enable_qos = false;
        enable_bw_control = false;
    }

For enable command:
There are 2 cases to consider, based on QOS type set on cluster level
1. If combined bandwith control is disabled
a. If qos_type is pershare, then export_writebw and export_readbw parameters are compulsory
b. If qos_type is perclient, then can't enable export level qos
c. If qos_type is pershare_perclient then export_writebw, export_readbw, client_writebw and
client_readbw are compulsory parameters
2. If combined bandwidth control is enabled
a. If qos_type is pershare, then export_rw_bw parameter is compulsory
b. If qos_type is perclient, then can't enable export level qos
c. If qos_type is pershare_perclient, then export_rw_bw and client_rw_bw parameters are compulsory

  • Export level qos can be enabled only when cluster level qos is enabled.
  1. To enable qos ratelimiting
    nfs export qos enable bandwidth_control <cluster_id> <pseudo_path> [--combined-rw-bw-ctrl] [--max_export_write_bw ] [--max_export_read_bw ] [--max_client_write_bw ] [--max_client_read_bw ] [--max_export_combined_bw ] [--max_client_combined_bw ]
  2. To disable qos
    nfs export qos disable bandwidth_control <cluster_id> <pseudo_path>
  3. to get qos config
    nfs export qos get <cluster_id> <pseudo_path> [--format ]

Existing command affected by this changes: nfs export apply <cluster_id> [--format ]

Tetsing logs:

[ceph: root@ceph-node-0 /]# ceph nfs cluster qos enable bandwidth_control mynfs PerShare --max_export_write_bw 10MB --max_export_read_bw 20MB                           
[
  "QOS bandwidth control has been successfully enabled. If the qos_type is changed during this process, ensure that the bandwidth values for all exports are updated accordingly."
]
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# ceph nfs cluster qos get mynfs
{
  "combined_rw_bw_control": false,
  "enable_bw_control": true,
  "enable_qos": true,
  "max_export_read_bw": "20.0MB",
  "max_export_write_bw": "10.0MB",
  "qos_type": "PerShare"
}
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# ceph nfs cluster qos disable bandwidth_control mynfs                                 
[
  "Cluster-level QoS bandwidth control has been successfully disabled. As a result, export-level bandwidth control will no longer have any effect, even if it's enabled."
]
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# ceph nfs cluster qos get mynfs
{
  "combined_rw_bw_control": false,
  "enable_bw_control": false,
  "enable_qos": false
}
[ceph: root@ceph-node-0 /]#
[ceph: root@ceph-node-0 /]# ceph nfs cluster qos enable bandwidth_control mynfs PerShare --max_export_write_bw 10MB --max_export_read_bw 10MB
[
  "QOS bandwidth control has been successfully enabled. If the qos_type is changed during this process, ensure that the bandwidth values for all exports are updated accordingly."
]
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# ceph nfs export qos enable bandwidth_control mynfs /export1 --max_export_write_bw=20MB --max_export_read_bw=20MB
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# ceph nfs export qos get mynfs /export1                                              
{
  "combined_rw_bw_control": false,
  "enable_bw_control": true,
  "enable_qos": true,
  "max_export_read_bw": "20.0MB",
  "max_export_write_bw": "20.0MB"
}
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# ceph nfs export info mynfs /export1   
{
  "access_type": "RW",
  "clients": [],
  "cluster_id": "mynfs",
  "export_id": 1,
  "fsal": {
    "cmount_path": "/",
    "fs_name": "myfs",
    "name": "CEPH",
    "user_id": "nfs.mynfs.myfs.126d1904"
  },
  "path": "/",
  "protocols": [
    3,
    4
  ],
  "pseudo": "/export1",
  "qos_block": {
    "combined_rw_bw_control": false,
    "enable_bw_control": true,
    "enable_qos": true,
    "max_export_read_bw": "20.0MB",
    "max_export_write_bw": "20.0MB"
  },
  "security_label": true,
  "squash": "none",
  "transports": [
    "TCP"
  ]
}
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# 
[ceph: root@ceph-node-0 /]# ceph nfs export qos disable bandwidth_control mynfs /export1                         
[ceph: root@ceph-node-0 /]# ceph nfs export info mynfs /export1
{
  "access_type": "RW",
  "clients": [],
  "cluster_id": "mynfs",
  "export_id": 1,
  "fsal": {
    "cmount_path": "/",
    "fs_name": "myfs",
    "name": "CEPH",
    "user_id": "nfs.mynfs.myfs.126d1904"
  },
  "path": "/",
  "protocols": [
    3,
    4
  ],
  "pseudo": "/export1",
  "qos_block": {
    "combined_rw_bw_control": false,
    "enable_bw_control": false,
    "enable_qos": false
  },
  "security_label": true,
  "squash": "none",
  "transports": [
    "TCP"
  ]
}
[ceph: root@ceph-node-0 /]# ceph nfs export qos get mynfs /export1
{
  "combined_rw_bw_control": false,
  "enable_bw_control": false,
  "enable_qos": false
}
[ceph: root@ceph-node-0 /]# 

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

@ShwetaBhosale1 ShwetaBhosale1 changed the title mgr/nfs: NFS commands to enable, disable and get QOS config for clust… mgr/nfs: NFS commands to enable, disable and get QOS config for cluster and export Jan 9, 2025
@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch 2 times, most recently from 7efdc68 to 5638aa6 Compare January 10, 2025 09:18
@ShwetaBhosale1
ShwetaBhosale1 marked this pull request as ready for review January 10, 2025 09:19
@ShwetaBhosale1
ShwetaBhosale1 requested a review from a team as a code owner January 10, 2025 09:19
Comment thread src/python-common/ceph/utils.py Resolved
@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch from 5638aa6 to e54c5b6 Compare January 10, 2025 12:40
@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch 3 times, most recently from f738e59 to 168dda6 Compare January 28, 2025 10:46
@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch 2 times, most recently from c5aa8a8 to 6e56e2c Compare January 30, 2025 16:24
@adk3798

adk3798 commented Feb 6, 2025

Copy link
Copy Markdown
Contributor

jenkins retest this please

1 similar comment
@ShwetaBhosale1

Copy link
Copy Markdown
Contributor Author

jenkins retest this please

@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch 3 times, most recently from dc3b4cd to 9d218ea Compare February 7, 2025 06:25
@ShwetaBhosale1

Copy link
Copy Markdown
Contributor Author

jenkins test api

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

There's nothing here that looks like it wouldn't work to me (assuming the way the blocks are being formatted with the QoS parameters the way ganesha is expecting). I have a handful of minor comments below. Beyond that, as a high level thing, I think this might be easier to follow if we tried to convert sets of QoS parameters into the QoS object you created ASAP and then only turn it back into block/dict form at the last second when we have to. When I see things like

           if kwargs:
                export.qos_block.update_bandwidths(**kwargs)
            else:
                export.qos_block.update_bandwidths('0', '0', '0', '0', '0', '0')

or

self.update_cluster_qos(cluster_id, True, True, combined_bw_ctrl, qos_type, **kwargs)

and

self.update_cluster_qos(cluster_id, False, False, False)

I can't help but think it would be easier to understand if we passed a QOS object that encapsulates all these parameters rather than passing a bunch of values and having unknown "kwargs" included. On that same note, I'm wondering if we should attach the QOS validation/check functions to the QOS object (and maybe move these new QOS things into their own file given there's a number of them) just to have them in one place. But overall, this seems like it gets the job done.

Comment thread src/python-common/ceph/utils.py Resolved
Comment thread src/pybind/mgr/nfs/ganesha_conf.py Outdated
Comment on lines 343 to 345

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.

unless there's a reason not to, I'd think we want those attributes to be like

per_share = 'PerShare'

so that we could do checks like if <qos-type> == QOSType.per_share. I saw one instance of

if clust_qos_obj.qos_type == QOSType._2:

during review and something like that would be easier to understand with the naming scheme I'm suggesting.

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.

I have updated it to below as we need to map qos_type to int. Let me know if it looks ok?

class UserQoSType(Enum):
    per_share = 'PerShare'
    per_client = 'PerClient'
    per_share_per_client = 'PerShare_PerClient'


class QOSType(Enum):
    PerShare = 1
    PerClient = 2
    PerShare_PerClient = 3

Comment thread src/pybind/mgr/nfs/ganesha_conf.py Resolved
Comment thread src/pybind/mgr/nfs/cluster.py Resolved
Comment thread src/pybind/mgr/nfs/ganesha_conf.py Resolved
Comment thread src/pybind/mgr/nfs/export.py Resolved
Comment thread src/pybind/mgr/nfs/export.py Resolved
Comment thread src/pybind/mgr/nfs/tests/test_nfs.py Resolved
@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch 2 times, most recently from ba3bb61 to 3456ed0 Compare February 10, 2025 08:17
@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch 3 times, most recently from 66c81bb to 6dd4f5e Compare February 10, 2025 14:43

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

LGTM assuming the blocks being written match what ganesha is expecting. Will have to see once a version is released we can test with

Comment thread src/pybind/mgr/nfs/cluster.py Resolved
@ShwetaBhosale1
ShwetaBhosale1 force-pushed the fix_issue_69458_nfs_ratelimiting_commands_for_cluster_and_export branch from 6dd4f5e to 2a0875e Compare February 11, 2025 07:46
@ShwetaBhosale1

Copy link
Copy Markdown
Contributor Author

jenkins test api

@ShwetaBhosale1

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@ShwetaBhosale1

Copy link
Copy Markdown
Contributor Author

jenkins test api

@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

@ShwetaBhosale1

Copy link
Copy Markdown
Contributor Author

Closing this PR as this commit is already there in PR: #61826

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.

2 participants