Skip to content

mon: allow setting/unsetting multiple OSD flags in one command - #69587

Merged
anthonyeleven merged 1 commit into
ceph:mainfrom
lumir-sliva:osd-set-multiple-flags
Nov 22, 2026
Merged

anthonyeleven merged 1 commit into
ceph:mainfrom
lumir-sliva:osd-set-multiple-flags

Conversation

@lumir-sliva

@lumir-sliva lumir-sliva commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

ceph osd set and ceph osd unset only accepted a single flag per invocation, so an operator preparing for maintenance had to run one command per flag:

ceph osd set noout
ceph osd set nobackfill
ceph osd set norebalance

Passing several at once failed with a confusing parser error (nobackfill not one of 'true', 'false') because the extra words were matched against the optional yes_i_really_mean_it boolean.

This makes both commands accept one or more flags (n=N). The handler validates every flag first and applies them as a single OSD map update, so either all of the requested flags are set/unset or, if any flag is invalid, none are and the command is rejected. The per-flag name-to-bit mapping that was duplicated between the two handlers is pulled into a small helper.

A single flag still behaves exactly as before, and the completion message now agrees its verb with the number of flag names it reports, so one flag reads noout is set while several read nobackfill,noout are set.

Compatibility with callers that build the command themselves

Declaring the argument n=N changes the JSON the monitor receives from "key": "noout" to "key": ["noout"]. The CLI adapts on its own, but callers that assemble the command directly do not, and cmd_getval() matches the variant type exactly. Reading only a vector<string> would have failed all of these with -EINVAL "bad or missing field 'key'":

  • pg_autoscaler/module.py, which backs ceph osd pool set/unset noautoscale
  • dashboard/controllers/osd.py _update_flags(), behind the OSD Flags page
  • test/pybind/test_rados.py, six sites, each asserting eq(r, 0)
  • ceph_test_rados_io_sequence, via OSDSetRequest which holds key as a std::string

The pg_autoscaler case fails silently, since it does not check the return value: ceph osd pool set noautoscale would report success without setting the flag. Both shapes are therefore accepted, which keeps those callers working untouched.

Testing

Besides the added cephtool/test.sh cases, verified on a vstart cluster:

  • ceph osd set norecover nobackfill norebalance sets all three in one command, ceph osd unset clears several at once
  • a single flag behaves exactly as before, and pause reports both of its bits
  • an invalid flag anywhere in the list rejects the whole command and applies none of them
  • pglog_hardlimit combined with another flag still honors its feature/release guard
  • an empty flag list is rejected by the CLI up front and by the monitor when sent as a raw mon_command
  • a flag passed as a bare string still works, and ceph osd pool set/unset noautoscale round-trips correctly
  • the six test_rados.py tests that pass key as a bare string pass

Tracker: https://tracker.ceph.com/issues/77397

Checklist

  • Tracker (select at least one)
    • References tracker ticket
  • Component impact
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
  • Tests (select at least one)
    • Includes integration test(s)

@lumir-sliva
lumir-sliva requested review from a team as code owners June 18, 2026 17:34
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@anthonyeleven

Copy link
Copy Markdown
Contributor

Nice!

I left a couple suggestions. Once the tests pass we can flag for qa

Comment thread doc/man/8/ceph.rst Outdated
@@ -1399,13 +1399,14 @@ Usage::

ceph osd scrub <who>

Subcommand ``set`` sets cluster-wide <flag> by updating OSD map.
Subcommand ``set`` sets cluster-wide <flag> by updating OSD map. More than

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.

While you’re here:

the OSD map

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.

While you're here: the OSD map

Done.

Comment thread src/mon/MonCommands.h Resolved
Comment thread doc/man/8/ceph.rst Resolved
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

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

@lumir-sliva
lumir-sliva force-pushed the osd-set-multiple-flags branch from c16f285 to c5acc6b Compare August 4, 2026 16:41

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

LGTM! Implementation is the most sincere form of flattery. We'll need someone from @ceph/core to approve the code bits.

@anthonyeleven

Copy link
Copy Markdown
Contributor

@ljflores @adamemerson Thoughts on who might be a good reviewer for the code?

@adamemerson

Copy link
Copy Markdown
Contributor

@ljflores @adamemerson Thoughts on who might be a good reviewer for the code?

Maybe @aainscow ?

@aainscow

aainscow commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I can look at this when I am back from PTO.

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

Overall, looks good. I have some improvements to request:

  1. Replace the if (!flags) test with an assert.
  2. Fix the grammar for setting multiple flags.
  3. Further updates to the docs. You have the basic man page - but you have not updated anything in the main docs. There are a few places which could benefit from this multi-flag set.
  4. Better testing. You have some basic tests - but they don't check error messages or completion messages and don't check some edge cases like no flags.

Comment thread src/mon/OSDMonitor.cc Resolved
Comment thread src/mon/OSDMonitor.cc Resolved
Comment thread src/mon/OSDMonitor.cc Resolved
Comment thread src/mon/OSDMonitor.cc Resolved
Comment thread src/mon/OSDMonitor.cc Resolved
`ceph osd set` and `ceph osd unset` only accepted a single flag per
invocation, so an operator preparing for maintenance had to run one
command per flag:

  ceph osd set noout
  ceph osd set nobackfill
  ceph osd set norebalance

Passing several at once failed with a confusing parser error
("nobackfill not one of 'true', 'false'") because the extra words were
matched against the optional yes_i_really_mean_it boolean.

Accept one or more flags (n=N) for both commands. The handler now
validates every flag first and applies them as a single OSD map update,
so either all of the requested flags are set/unset or, if any flag is
invalid, none are and the command is rejected. The per-flag
name-to-bit mapping that was duplicated between the two handlers is
pulled into a small helper.

Declaring the argument n=N changes the JSON the monitor receives from a
bare string to a list. The CLI adapts on its own, but callers that build
the command themselves do not: the pg_autoscaler and dashboard mgr
modules, and ceph_test_rados_io_sequence, all still send a string, and
cmd_getval() matches the variant type exactly. Reading only a list would
have failed those with "bad or missing field 'key'", which in the
pg_autoscaler case is silent because it does not check the return, so
`ceph osd pool set noautoscale` would report success without setting the
flag. Both shapes are therefore accepted.

A single flag still behaves exactly as before. The completion message
now agrees its verb with the number of flag names it reports, so one
flag still reads "noout is set" while several read "nobackfill,noout
are set".

Updates the usage strings, the man page, and the cluster flag sections
of the health-check and OSD troubleshooting docs. Extends the cephtool
test to cover the completion and error messages, a repeated flag, a
rejected flag mixed with a valid one, an empty flag list, and a flag
passed as a bare string.

Tracker: https://tracker.ceph.com/issues/77397
Signed-off-by: Slíva, Lumír <[email protected]>
@lumir-sliva
lumir-sliva force-pushed the osd-set-multiple-flags branch from c5acc6b to f506368 Compare August 12, 2026 09:13
@lumir-sliva
lumir-sliva requested a review from aainscow August 18, 2026 09:52

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

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

LGTM

thanks, can we move it forward please?

@anthonyeleven

Copy link
Copy Markdown
Contributor

The flags should get this batched up for qa and merge.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath24-testing-20260918.001059-main.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

@lumir-sliva Please resolve the PR checks and proceed with merging the PR once all checks have passed. If a rerun is required, remove the Tested label and add the needs-qa label.

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

@anthonyeleven @aainscow can anyone of you pleae put the the LABELS in I'm not part of the org, I cant. thanks!

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

jenkins test api

@anthonyeleven
anthonyeleven merged commit c033d83 into ceph:main Nov 22, 2026
20 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/45025387208

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.

7 participants