Skip to content

rgw/radosgw-admin: extract account commands into a module (1 of 2) - #71575

Open
RaminNietzsche wants to merge 1 commit into
ceph:mainfrom
RaminNietzsche:wip-rgw-admin-account
Open

RaminNietzsche wants to merge 1 commit into
ceph:mainfrom
RaminNietzsche:wip-rgw-admin-account

Conversation

@RaminNietzsche

@RaminNietzsche RaminNietzsche commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

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.

Context (incremental split from #71462)

This is slice 3 in the incremental landing plan for the radosgw-admin modularization work in #71462.

This PR contains only the account module extraction and its exit-code tests. It rebases on current ceph/main (tip f34858371464 as of 2026-10-27), which already includes merged #71569 and #71570; this diff does not reintroduce those changes.

Enum placement: account_command stays module-local while CLI11 #69145 is unresolved, per cbodley/chardan guidance on #71462. Shared types from radosgw-admin.h (#71570) are used where applicable; command enums are not centralized into opt_*.inc yet.

Known unchanged behavior: negative --max-entries is still accepted (same as before this extraction).

Summary

  • Add account.h / account.cc with rgw_admin_account() for account create/modify/get/stats/rm/list
  • Add util.h with shared rgw_admin::report_error() for consistent CLI error output
  • Wire dispatch from radosgw-admin.cc through rgw_admin_account_options
  • Move account list metadata iteration out of the shared user/metadata list block into the account module
  • Add account.cc to the radosgw-admin CMake target
  • Add shell exit-code tests: test-account-exit-codes.sh and shared helpers

Supported account commands and flags are unchanged.

Testing

Local build and tests (Release, WITH_RADOSGW_RADOS=ON, vstart cluster):

  • ninja radosgw-admin
  • cram src/test/cli/radosgw-admin/help.t — passed
  • bash src/test/rgw/radosgw-admin/test-account-exit-codes.sh — passed
  • ninja ceph_test_cls_rgw_admin_account_quota_set — built and run (exit 0)
  • Manual smoke: account list, account list --max-entries=2, account get, account stats, create/get/rm cycle

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

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@RaminNietzsche
RaminNietzsche requested review from a team as code owners September 7, 2026 07:37
@RaminNietzsche

Copy link
Copy Markdown
Member Author

This PR is slice 3 of the incremental radosgw-admin modularization plan spun out of #71462.

It depends on the earlier slices already open as #71569 (remove unused CLI locals/macros) and #71570 (extract command types into a header). The branch stacks those commits so the account module can be built and reviewed as one diff; after the prerequisites merge I will rebase to leave only the account extraction commit.

What this change does:

  • Moves account create/modify/get/stats/rm/list into account.cc
  • Routes dispatch through rgw_admin_account() and rgw_admin_account_options
  • Keeps user list with --account-id / --account-name in radosgw-admin.cc (user command, not account module scope)

Local verification on a vstart cluster (WITH_RADOSGW_RADOS=ON):

  • ninja radosgw-admin
  • cram src/test/cli/radosgw-admin/help.t
  • ceph_test_cls_rgw_admin_account_quota_set (exit 0)
  • smoke: account list, account list --max-entries=2, account get, account stats, create/get/rm cycle

Happy to rebase once #71569 and #71570 land, or adjust the split order if reviewers prefer a different sequencing.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

Rebased this PR onto current main so it now contains only the account module slice (2 commits):

  1. rgw/radosgw-admin: extract account commands into a module
  2. test/rgw: add radosgw-admin account exit-code tests

Removed from this branch:

The account module uses a module-local account_command enum instead of depending on a shared admin header, so this slice can land independently of the earlier PRs.

Added exit-code tests from the modularization series:

  • src/test/rgw/radosgw-admin/test-account-exit-codes.sh
  • src/test/rgw/radosgw-admin/test-radosgw-admin-exit-codes-common.sh
  • wired via add_ceph_test in src/test/rgw/CMakeLists.txt

Local verification: ninja radosgw-admin, cram help.t, and test-account-exit-codes.sh all passed on a vstart cluster.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

Pushed a follow-up commit addressing review findings:

Local verification on stg-hd1:

  • ninja radosgw-admin — OK
  • test-account-exit-codes.sh — CI sim: 56 passed / 0 failed / 24 skipped; with vstart: 85 passed / 1 failed (list: --max-entries negative — pre-existing: -1 is accepted by the CLI parser today)

@RaminNietzsche

Copy link
Copy Markdown
Member Author

jenkins test windows

@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

@RaminNietzsche

Copy link
Copy Markdown
Member Author

Rebased onto current main (169a0fb3a86c). New tip: f34858371464.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

jenkins test make check

@RaminNietzsche

RaminNietzsche commented Oct 28, 2026 •

Copy link
Copy Markdown
Member Author

@cbodley @ivancich @chardan — ready for review (slice 3 / incremental landing from #71462).

Behavior-neutral extraction only; negative --max-entries acceptance unchanged. Feedback on sequencing vs #71578 welcome.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

@chardan Thank you for reviewing #71578 and the umbrella. This account-module slice is independent of #71578 (both carry the same util.h helper, so either can merge first). Checks are green on tip f34858371464. Would you mind taking a look? I will mark the series order in the titles as you suggested.

@RaminNietzsche RaminNietzsche changed the title rgw/radosgw-admin: extract account commands into a module rgw/radosgw-admin: extract account commands into a module (1 of 2) Nov 8, 2026
@RaminNietzsche

Copy link
Copy Markdown
Member Author

Rebased on current main (tip 9609df75906). radosgw-admin builds; src/test/rgw/radosgw-admin/test-account-exit-codes.sh — 86 passed, 0 failed on vstart (test environment).

@chardan — ready for review when you have a cycle (series 1/2; #71578 approved).

jenkins test make check

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

Not sure how this got tagged for docs but LGTM

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

A couple of things you may want to look at, but it might be best to avoid more mechanism changes. Take a peek and thing it over a bit. But, +1, looks good to me-- thank you for your work on this!

Comment thread src/rgw/radosgw-admin/account.cc Outdated
int ret = 0;

switch (o.command) {
case account_command::create:

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.

Another indent level here would be nice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 67bcacc14dc: indented case labels and bodies in both switches in account.cc (same style as the account dispatch switch in radosgw-admin.cc, which already had the extra level). Thanks for the nit.

Comment thread src/rgw/radosgw-admin/account.cc Outdated
case account_command::create:
ret = rgw::account::create(dpp, driver, op_state, err_msg,
stream_flusher, null_yield);
if (ret < 0) {

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.

Have you considered using exceptions here instead? It would probably simplify this code quite a bit-- you could have something like "account operation failed ({}): {}", ret, err_msg)". Not required, but it might be nice while we're in here.

Then again, if this is how it's already written, let's not touch it for now, that's a future PR!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed — not for this structural slice. I added it to my admin modularization follow-up list (A1) and plan a dedicated PR after slice 4 so we can settle error-handling style for the module handlers as a series, rather than only here. Keeping ret + report_error in #71575 as you suggested.


rgw::account::AdminOpState make_op_state(const rgw_admin_account_options& o)
{
return rgw::account::AdminOpState{

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.

Any reason this isn't just an ordinary constructor..? I'm ok with this factory, but am just wondering. Come to think of it, I think I just answered my own question: probably because you can't use deduction guides on that type without changing it. Never mind, then. :-)
(Also, I remind myself that this is a structural PR!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same follow-up list (A2): revisit ctor vs small factory after #71578 lands and once CLI11 #69145 clarifies type layout. For this PR I kept make_op_state() as you concluded in the thread — no change needed here.

RaminNietzsche added a commit to RaminNietzsche/ceph that referenced this pull request Nov 20, 2026
Indent case labels and bodies in account.cc (both switches) per review
on ceph#71575; dispatch switch in radosgw-admin.cc already matched.

Fixes: https://tracker.ceph.com/issues/80264
Signed-off-by: ramin.najarbashi <[email protected]>
@RaminNietzsche

Copy link
Copy Markdown
Member Author

@chardan Thank you for the review and approval, and for the detailed inline notes. I really value your experience on the admin modularization work — I will keep using your suggestions, and please keep flagging anything you think would improve the series even when it is not required for the current slice.

1. Switch indentation — Done in tip 67bcacc14dc. I indented case labels and bodies in both switch statements in account.cc. I also checked the other changes in this PR: the account command dispatch switch in radosgw-admin.cc already used the extra indent level, so I left it as-is.

2. Exceptions vs ret + report_error — I agree this should not land in a structural extraction PR. I added it to my admin modularization follow-up list (tracked locally as backlog item A1) and plan to come back with a dedicated PR after slice 4, so we can discuss error-handling style for the modules as a whole rather than only in account.cc.

3. make_op_state / constructor — Same plan: noted on the follow-up list (backlog item A2) to revisit AdminOpState construction after #71578 and once CLI11 #69145 clarifies the type layout, without expanding scope here. For this PR I kept the small factory as you suggested in the thread.

Thanks again for your time on this slice.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

jenkins test make check

Move account create/modify/get/stats/rm/list handling from
radosgw-admin.cc into account.cc with shared error reporting via
util.h. Wire dispatch through rgw_admin_account() using a module-local
account_command enum so this slice does not depend on a shared
radosgw-admin header.

Add shell-based exit-code coverage (test-account-exit-codes.sh and
shared helpers). Guard tests with WITH_RADOSGW_RADOS. Use
RGWFormatterFlusher& in the module to match rgw_account.h and the
sibling user slice; ceph_abort() on the outer dispatch default;
document handle_account_list duplication versus admin_meta (ceph#71578).
Indent switch case labels and bodies in account.cc per review.

Behavior of supported account commands and flags is unchanged.

Signed-off-by: ramin.najarbashi <[email protected]>
@anrao19

anrao19 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao17-testing-2026-12-02-0607-main.

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.

4 participants