Skip to content

tentacle: mgr/DaemonServer: Implement ok-to-upgrade command - #66948

Merged
batrick merged 3 commits into
ceph:tentaclefrom
sseshasa:wip-ok-to-upgrade-backport-tentacle
Apr 7, 2026
Merged

batrick merged 3 commits into
ceph:tentaclefrom
sseshasa:wip-ok-to-upgrade-backport-tentacle

Conversation

@sseshasa

@sseshasa sseshasa commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

This is a manually created tentacle backport of PR: #66108.
The 'main' PR is reviewed and awaiting teuthology testing.

The intent of this backport is ensure that a tentacle branch is ready for cherry-picking once
the downstream branch is created.

Description (from 'main' PR)

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":[]}

Backport Tracker: https://tracker.ceph.com/issues/75106

backport of #66108
parent tracker: https://tracker.ceph.com/issues/73031

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.

@sseshasa

Copy link
Copy Markdown
Contributor Author

/config check ok

@sseshasa
sseshasa force-pushed the wip-ok-to-upgrade-backport-tentacle branch from cca6687 to 0fc851e Compare February 19, 2026 06:03
@sseshasa

Copy link
Copy Markdown
Contributor Author

@rzarzynski @kamoltat @NitzanMordhai Please approve this tentacle backport so that teuthology tests can be completed in parallel to the main PR and make this feature available on downstream 9.1 soon. Thanks!

@sseshasa
sseshasa force-pushed the wip-ok-to-upgrade-backport-tentacle branch from 0fc851e to 1a65d0d Compare February 19, 2026 13:45
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test api

@sseshasa
sseshasa force-pushed the wip-ok-to-upgrade-backport-tentacle branch from 1a65d0d to 9c838bc Compare February 23, 2026 07:28
@sseshasa

Copy link
Copy Markdown
Contributor Author

@rzarzynski @kamoltat @NitzanMordhai Can anyone of you please approve this tentacle backport? 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.

LGTM

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@sseshasa just make sure you are fixing the make error

@sseshasa

Copy link
Copy Markdown
Contributor Author

@sseshasa just make sure you are fixing the make error

That's interesting. I didn't see this on main. I will check and fix it. Thanks for pointing it out.

@sseshasa
sseshasa force-pushed the wip-ok-to-upgrade-backport-tentacle branch from 9c838bc to 7eb38e9 Compare February 23, 2026 19:29
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]>
(cherry picked from commit cf54988)

Conflicts:
    src/mgr/DaemonServer.cc
- In DaemonServer::_check_offlines_pgs(), resolve a compiler error
  when printing the list of osds which is of type std::variant. Since
  tentacle branch is still not transitioned to use std::variant
  instead of boost::variant, the operator<< is not handled like in the
  main branch(see commit: 09d2731). Therefore, use std::visit() to
  print the list of osds that could be of types std::set or
  std::vector by using a lambda and passing the CephContext pointer
  and a pointer to the offline pg report.
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]>
(cherry picked from commit c63b188)
…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]>
(cherry picked from commit 8177e48)
@sseshasa
sseshasa force-pushed the wip-ok-to-upgrade-backport-tentacle branch from 7eb38e9 to f5b7e3e Compare February 24, 2026 02:42
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@sseshasa

Copy link
Copy Markdown
Contributor Author

@sseshasa just make sure you are fixing the make error

That's interesting. I didn't see this on main. I will check and fix it. Thanks for pointing it out.

@NitzanMordhai In short, the compilation error was because std::variant not having the overload of operator>>. In tentacle, boost::variant is still being used. But in 'main', boost::variant is replaced by std::variant along with the overload of operator>> to help print this type. See commit 09d2731. Therefore, in tentacle, printing std::variant requires the use of std::visit() which I have now added to that dout() line. I have also noted all the details under the ''conflict" section in the commit message.

@sseshasa

sseshasa commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Teuthology Test Results

Rados Suite - All failures are unrelated

https://pulpito.ceph.com/sseshasa-2026-02-26_14:56:45-rados-wip-sseshasa-testing-2026-02-26-1772100687-distro-default-trial/

243/272 Jobs Passed, 28 Failed, 1 Dead.

Based on the results shown below, the PR may be merged when the window opens for tentacle branch.

All Failures, Dead jobs are Unrelated

  1. ['72501', '72443', '72439', '72321', '72307', '72257', '72380'] - https://tracker.ceph.com/issues/74332 - ceph-kvstore-tool segfault in workunits/cephtool/test_kvstore_tool.sh
  2. ['72266'] - https://tracker.ceph.com/issues/70716 - rados/thrash-old-clients: "pg backfill_toofull" warning in cluster log
  3. ['72275', '72511'] - https://tracker.ceph.com/issues/71506 - Unhandled exception from module 'dashboard' while running on mgr.y: Timeout('Port 8443 not free on ::.')
  4. ['72284', '72423'] - https://tracker.ceph.com/issues/62972 - ERROR: test_list_enabled_module (tasks.mgr.dashboard.test_mgr_module.MgrModuleTest) - (Dashboard)
  5. ['72285'] - https://tracker.ceph.com/issues/73921 - rados/encoder: Container image quay.ceph.io/ceph-ci/ceph:quincy with tag quincy not found leading
  6. ['72450', '72312'] - https://tracker.ceph.com/issues/74517 - drop.ceph.com is unreachable (ceph-post-file)https://tracker.ceph.com/issues/74517 - drop.ceph.com is unreachable (ceph-post-file)
  7. ['72333'] - https://tracker.ceph.com/issues/70772 - rados/verify: rados/test.sh hangs indefinitely after completing all api tests successfully.
  8. ['72350'] - https://tracker.ceph.com/issues/71344 - Monitor Reconnection Failure and MON_NETSPLIT due to Stale Global Sequence Check During Incoming Connection
  9. ['72356', '72493'] - https://tracker.ceph.com/issues/68668 - rados/dashboard: mkfs.xfs: cannot open /dev/vg_nvme/lv_2: Device or resource busy
  10. ['72389'] - https://tracker.ceph.com/issues/72747 - No InfluxDB server configured (MGR_INFLUX_NO_SERVER)
  11. ['72408'] - https://tracker.ceph.com/issues/74717 - Failed to reconnect to trialXXX after kernel update
  12. ['72421'] - https://tracker.ceph.com/issues/71005 - qa/tasks/backfill_toofull.py line 155 - assert backfillfull < 0.9 - for test with compression
  13. ['72432'] - https://tracker.ceph.com/issues/70320 - test_osd_came_back fails when test does not detect that osd.0 is back in
  14. ['72454'] - https://tracker.ceph.com/issues/74827 - TEST_mon_features fails due to hardcoded feature count - missing nvmeof_beacon_diff
  15. ['72480'] - https://tracker.ceph.com/issues/74524 - TEST_backfill_pool_priority: "The primary PG X.X didn't become the in progress item on remote"
  16. ['72481'] - https://tracker.ceph.com/issues/55838 - "download_cephadm" step fails
  17. ['72482'] - https://tracker.ceph.com/issues/74679 - Jammy packages fail to install on trial nodes
  18. ['72508'] - https://tracker.ceph.com/issues/74525 - TEST_bluestore_expand fails on "free space added" check (osd-bluefs-volume-ops.sh)
  19. https://tracker.ceph.com/issues/68586 - cephadm: task/test_iscsi_container test hits max timeout - (Orchestrator)

@sseshasa sseshasa added TESTED and removed needs-qa labels Mar 2, 2026
Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread src/mgr/DaemonServer.cc Resolved
Comment thread src/mgr/DaemonServer.cc Resolved
@sseshasa sseshasa modified the milestones: tentacle, v20.2.2 Apr 7, 2026
@batrick
batrick merged commit 6befa5e into ceph:tentacle Apr 7, 2026
7 checks passed
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