Skip to content

mgr/DaemonServer: Implement ok-to-upgrade command - #66108

Merged
sseshasa merged 3 commits into
ceph:mainfrom
sseshasa:wip-rfe-implement-ok-to-upgrade-command
Feb 23, 2026
Merged

sseshasa merged 3 commits into
ceph:mainfrom
sseshasa:wip-rfe-implement-ok-to-upgrade-command

Conversation

@sseshasa

@sseshasa sseshasa commented Nov 3, 2025 •

Copy link
Copy Markdown
Contributor

Implement a new Mgr command called 'ok-to-upgrade' that returns a set of OSDs within the provided CRUSH bucket that are safe to upgrade without reducing immediate data availability.

The command accepts the following as input:

  • CRUSH bucket name (required)
    • The CRUSH bucket type is checked and is limited to 'rack', 'chassis', 'host' and 'osd'. This is to prevent users-from specifying a bucket type higher up the tree which could result in performance issues if the number of OSDs in the bucket is very high.
  • The new Ceph version to check against. The format accepted is the short form of the Ceph version, for e.g. 20.3.0-3803-g63ca1ffb5a2. (required)
  • The maximum number of OSDs to consider if specified. (optional)

Implementation Details:

After sanity checks on the provided parameters, the following steps are performed:

  1. The set of OSDs within the CRUSH bucket is first determined.
  2. From the main set of OSDs, a filtered set of OSDs not yet running the new Ceph version is created.
    • For this purpose, the OSD's 'ceph_version_short' string is read from the metadata. For this purpose a new method called DaemonServer::get_osd_metadata() is used. The information is determined from the DaemonStatePtr maintained within the DaemonServer.
  3. If all OSDs are already running the new Ceph version, a success report is generated and returned.
  4. If OSDs are not running the new Ceph version, a new set (to_upgrade) is created.
  5. If the current version cannot be determined, an error is logged and the output report with 'bad_no_version' field populated with the OSD in question is generated.
  6. On the new set (to_upgrade), the existing logic in _check_offline_pgs() is executed to see if stopping any or all OSDs in the set as part of the upgrade can reduce immediate data availability.
    • If data availability is impacted, then the number of OSDs in the filtered set is reduced by a factor defined by a new config option called mgr_osd_upgrade_check_convergence_factor which is set to 0.8 by default.
    • The logic in _check_offline_pgs() is repeated for the new set.
    • The above is repeated until a safe subset of OSDs that can be stopped for upgrade is found. Each iteration reduces the number of OSDs to check by the convergence factor mentioned above.
  7. It must be noted that the default value of mgr_osd_upgrade_check_convergence_factor is on the higher side in order to help determine an optimal set of OSDs to upgrade. In other words, a higher convergence factor would help maximize the number of OSDs to upgrade. In this case the number of iterations and therefore the time taken to determine the OSDs to upgrade is proportional to the number of OSDs in the CRUSH bucket. The converse is true if a lower convergence factor is used.
  8. The number of OSDs determined is lower than the 'max' specified, then an additional loop is executed to determine if other children of the CRUSH bucket can be added to the existing set.
  9. Once a viable set is determined, an output report similar to the following is generated:

The output shown below is for a cluster running on a single node with 10 OSDs
and with replicated pool configuration:

$ ceph osd ok-to-upgrade incerta06 01.00.00-gversion-test --format=json
{"ok_to_upgrade":true,"all_osds_upgraded":false, "osds_in_crush_bucket":[0,1,2,3,4,5,6,7,8,9], "osds_ok_to_upgrade":[0],"osds_upgraded":[],"bad_no_version":[]}

The following report is shown if all OSDs are running the desired Ceph version:

$ ceph osd ok-to-upgrade --crush_bucket  localrack  --ceph_version 20.3.0-3803-g63ca1ffb5a2
{"ok_to_upgrade":false,"all_osds_upgraded":true, "osds_in_crush_bucket":[0,1,2,3,4,5,6,7,8,9],"osds_ok_to_upgrade":[],"osds_upgraded":[0,1,2,3,4,5,6,7,8,9],"bad_no_version":[]}'

The following report is shown if an incompatible CRUSH bucket type is specified:

$ ceph osd ok-to-upgrade --crush_bucket default --ceph_version 20.3.0-3868-ga6644e3ae94
Error EINVAL: crush bucket "default" of type "root" is incompatible for upgradability check; valid types are: 'rack', 'chassis', 'host' and 'osd'

A qa/standalone test is introduced that runs basic sanity test and exercises the logic on both replicated and erasure-coded pools by manipulating the min_size for a pool and check for upgradability.

Fixes: https://tracker.ceph.com/issues/73031
Signed-off-by: Sridhar Seshasayee [email protected]

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

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

@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown

Config Diff Tool Output

+ added: mgr_osd_upgrade_check_reduction_factor (mgr.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@sseshasa

sseshasa commented Nov 3, 2025 •

Copy link
Copy Markdown
Contributor Author

Note to reviewers:

Please provide feedback on the following,

Right now there's no check to restrict the type of CRUSH bucket type to consider. This can impact how long the command will take to run if the bucket type specified is higher up the tree. In such a case, the command may take a long time to return depending on the number of OSDs in the subtree. I guess the question is, should we limit the bucket types to a small subset like for e.g., "host", "chassis", "rack" and so on?

This obviously needs thorough testing on scaled cluster for correctness, performance and other bugs before merging.

@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from 9322d17 to 1c9b959 Compare November 3, 2025 12:00
@sseshasa
sseshasa requested review from adk3798 and rkachach November 4, 2025 06:27
@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from 1c9b959 to bf8da07 Compare November 4, 2025 10:40
@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from bf8da07 to f095082 Compare November 17, 2025 15:34
@sseshasa

Copy link
Copy Markdown
Contributor Author

Right now there's no check to restrict the type of CRUSH bucket type to consider. This can impact how long the command will take to run if the bucket type specified is higher up the tree. In such a case, the command may take a long time to return depending on the number of OSDs in the subtree. I guess the question is, should we limit the bucket types to a small subset like for e.g., "host", "chassis", "rack" and so on?

Update:
In the latest push, the above logic is implemented. The bucket types that can be specified is limited to "host", "chassis", "rack" and "osd".

@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from f095082 to a76f2bb Compare November 18, 2025 19:00
@github-actions github-actions Bot added the tests label Nov 18, 2025
@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch 5 times, most recently from cafd354 to 25bca93 Compare November 19, 2025 08:34
@sseshasa

Copy link
Copy Markdown
Contributor Author

/config check ok

@sseshasa

Copy link
Copy Markdown
Contributor Author

@rzarzynski @NitzanMordhai @kamoltat Can you please review this from Mgr perspective? Thanks!

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

@sseshasa please see my comments

Comment thread src/mgr/MgrCommands.h Resolved
Comment thread src/mgr/DaemonServer.cc Resolved

@kamoltat kamoltat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @sseshasa great work! I left some comments, let me know what you think!

Comment thread PendingReleaseNotes Resolved
Comment thread qa/standalone/misc/ok-to-upgrade.sh Resolved
Comment thread src/mgr/DaemonServer.h Resolved
Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread qa/standalone/misc/ok-to-upgrade.sh Resolved
@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from 25bca93 to 24201bc Compare December 9, 2025 18:29
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch 2 times, most recently from d59b7a3 to 142dd4b Compare February 13, 2026 02:57
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from 142dd4b to b1932d8 Compare February 13, 2026 08:46
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@rzarzynski rzarzynski 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!

Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread src/common/options/mgr.yaml.in Resolved
Comment thread src/mgr/DaemonServer.cc Resolved

@kamoltat kamoltat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM just one small change, maybe add an empty string test to your standalone.

Comment thread qa/standalone/misc/ok-to-upgrade.sh Resolved
@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from b1932d8 to d0ccd8a Compare February 18, 2026 16:32

@kamoltat kamoltat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from d0ccd8a to db3848d Compare February 19, 2026 13:08
@sseshasa

sseshasa commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@rzarzynski @kamoltat ,The latest push today(Feb 19, 2026) has a minor fix for issue described here that was hit during testing on a larger cluster. I think the PR is in good shape now.

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

The offline_pg_report structure to be used by both the 'ok-to-stop' and
'ok-to-upgrade' commands is modified to handle either std::set or std::vector
type containers. This is necessitated due to the differences in the way
both commands work. For the 'ok-to-upgrade' command logic to work optimally,
the items in the specified crush bucket including items found in the subtree
must be strictly ordered. The earlier std::set container re-orders the items
upon insertion by sorting the items which results in the offline pg check to
report sub-optimal results.

Therefore, the offline_pg_report struct is modified to use
std::variant<std::vector<int>, std::set<int>> as a ContainerType and handled
accordingly in dump() using std::visit(). This ensures backward compatibility
with the existing 'ok-to-stop' command while catering to the requirements of
the new 'ok-to-upgrade' command.

Signed-off-by: Sridhar Seshasayee <[email protected]>
Implement a new Mgr command called 'ok-to-upgrade' that returns a set of OSDs
within the provided CRUSH bucket that are safe to upgrade without reducing
immediate data availability.

The command accepts the following as input:
 - CRUSH bucket name (required)
   - The CRUSH bucket type is limited to 'rack', 'chassis', 'host' and 'osd'.
     This is to prevent users from specifying a bucket type higher up the tree
     which could result in performance issues if the number of OSDs in the
     bucket is very high.
 - The new Ceph version to check against. The format accepted is the short
   form of the Ceph version, for e.g. 20.3.0-3803-g63ca1ffb5a2. (required)
 - The maximum number of OSDs to consider if specified. (optional)

Implementation Details:

After sanity checks on the provided parameters, the following steps are
performed:

1. The set of OSDs within the CRUSH bucket is first determined.
2. From the main set of OSDs, a filtered set of OSDs not yet running the new
   Ceph version is created.
   - For this purpose, the OSD's 'ceph_version_short' string is read from
     the metadata. For this purpose a new method called
     DaemonServer::get_osd_metadata() is used. The information is determined
     from the DaemonStatePtr maintained within the DaemonServer.
3. If all OSDs are already running the new Ceph version, a success report is
   generated and returned.
4. If OSDs are not running the new Ceph version, a new set (to_upgrade) is
   created.
5. If the current version cannot be determined, an error is logged and the
   output report with 'bad_no_version' field populated with the OSD in question
   is generated.
6. On the new set (to_upgrade), the existing logic in _check_offline_pgs() is
   executed to see if stopping any or all OSDs in the set as part of the upgrade
   can reduce immediate data availability.
   - If data availability is impacted, then the number of OSDs in the filtered
     set is reduced by a factor defined by a new config option called
     'mgr_osd_upgrade_check_convergence_factor' which is set to 0.8 by default.
   - The logic in _check_offline_pgs() is repeated for the new set.
   - The above is repeated until a safe subset of OSDs that can be stopped for
     upgrade is found. Each iteration reduces the number of OSDs to check by
     the convergence factor mentioned above.
7. It must be noted that the default value of
   'mgr_osd_upgrade_check_convergence_factor' is on the higher side in order to
   help determine an optimal set of OSDs to upgrade. In other words, a higher
   convergence factor would help maximize the number of OSDs to upgrade. In this
   case, the number of iterations and therefore the time taken to determine the
   OSDs to upgrade is proportional to the number of OSDs in the CRUSH bucket.
   The converse is true if a lower convergence factor is used.
8. If the number of OSDs determined is lower than the 'max' specified, then an
   additional loop is executed to determine if other children of the CRUSH
   bucket can be added to the existing set.
9. Once a viable set is determined, an output report similar to the following is
   generated:

A standalone test is introduced that exercises the logic for both replicated
and erasure-coded pools by manipulating the min_size for a pool and check for
upgradability. The tests also performs other basic sanity checks and error
conditions.

The output shown below is for a cluster running on a single node with 10 OSDs
and with replicated pool configuration:

$ ceph osd ok-to-upgrade incerta06 01.00.00-gversion-test --format=json
{"ok_to_upgrade":true,"all_osds_upgraded":false,\
 "osds_in_crush_bucket":[0,1,2,3,4,5,6,7,8,9],\
 "osds_ok_to_upgrade":[0],"osds_upgraded":[],"bad_no_version":[]}

The following report is shown if all OSDs are running the desired Ceph version:

$ ceph osd ok-to-upgrade --crush_bucket  localrack \
  --ceph_version 20.3.0-3803-g63ca1ffb5a2
{"ok_to_upgrade":false,"all_osds_upgraded":true,\
 "osds_in_crush_bucket":[0,1,2,3,4,5,6,7,8,9],"osds_ok_to_upgrade":[],\
"osds_upgraded":[0,1,2,3,4,5,6,7,8,9],"bad_no_version":[]}'

Fixes: https://tracker.ceph.com/issues/73031
Signed-off-by: Sridhar Seshasayee <[email protected]>
…upgrade

DaemonServer::_maximize_ok_to_upgrade_set() attempts to find which OSDs
from the initial set found as part of _populate_crush_bucket_osds() can be
upgraded as part of the initial phase. If the initial set results in failure,
the convergence logic trims the 'to_upgrade' vector from the end until a safe
set is found.

Therefore, it would be advantageous to sort the OSDs by the ascending number
of PGs hosted by the OSDs. By placing OSDs with smallest (or no PGs) at the
beginning of the vector, the trim logic along with _check_offlines_pgs() will
have the best chance of finding OSDs to upgrade as it approaches a grouping
of OSDs that have the smallest or no PGs.

To achieve the above, a temporary vector of struct pgs_per_osd is created and
sorted for a given crush bucket. The sorted OSDs are pushed to the main
crush_bucket_osds that is eventually used to run the _check_offlines_pgs()
logic to find a safe set of OSDs to upgrade.

pgmap is passed to _populate_crush_bucket_osds() to utilize get_num_pg_by_osd()
for the above logic to work.

Signed-off-by: Sridhar Seshasayee <[email protected]>
@sseshasa
sseshasa force-pushed the wip-rfe-implement-ok-to-upgrade-command branch from db3848d to 8177e48 Compare February 23, 2026 07:20
@sseshasa

Copy link
Copy Markdown
Contributor Author

The latest push today(Feb 23, 2026) is after a general rebase and to re-trigger unrelated failed checks. It also potentially has a fix for a minor issue described here that was hit during testing on a larger cluster.

@sseshasa

Copy link
Copy Markdown
Contributor Author

@sseshasa
sseshasa merged commit 0fac004 into ceph:main Feb 23, 2026
6 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/22306871716

@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/22306871716

@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/22306871716

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